Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to find nearest date in select sql
Message
De
20/01/2007 07:02:56
 
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:
01187316
Vues:
30
Then it should be something along these lines:
local ldfirst,ldend,lcfishcode1,lcfischcode2

ldfirst=thisform.txtd1.value
ldend=thisform.txtd2.value
lcfischcode1=[001] && sales fische type
lcfischcode2=[002] && sales fische type

select sum(quantity*price)/sum(quantity) as navgpriceS from ??? where fischetype= m.lcfishcode1 and ;
between(ldate,m.ldfirst,m.ldend) into cursor CrsSales

select sum(quantity*price)/sum(quantity) as navgpriceB from ??? where fischetype= m.lcfishcode2 and ;
between(ldate,m.ldfirst,m.ldend) into cursor CrsBuyings

If _tally=0
   select sum(quantity*price)/sum(quantity) as navgpriceB from ??? where fischetype= m.lcfishcode2 and ;
   m.ldfirst-ldate in (Select Min(m.ldfirst-ldate) from ??? where ldate<=m.ldfirst) into cursor CrsBuyings
EndIf
By the way, actually avg(price) won't work, as it will not take into account the quantity.

And you need to fill in from ???, from which table you want to select....

Bye, Olaf.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform