Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to find nearest date in select sql
Message
From
18/01/2007 11:58:28
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01186568
Message ID:
01186706
Views:
23
> sum(quantity)*sum(price)/sum(quantity)

I'd say you need sum(quantity*price)/sum(quantity) for the average price, or simply avg(price).
sum(quantity)*sum(price)/sum(quantity) is definately equal to sum(price), which is not the avarage price.

For your main question: You need a third select if the second one has no result, I don't see a way to put it inside a single SQL select.

The question is, do you want to take nearest date after m.ldend or nearest before m.ldfirst
or nearest to any of those two dates?

Bye, Olaf.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform