Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to find nearest date in select sql
Message
De
18/01/2007 11:58:28
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01186568
Message ID:
01186706
Vues:
31
> 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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform