Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Elegant SQL
Message
De
11/05/2005 12:12:08
 
 
À
11/05/2005 11:45:17
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01012923
Message ID:
01012947
Vues:
23
This message has been marked as the solution to the initial question of the thread.
>Hi All:
>
>Is there any way to consolidate the following code in to one SQL statement?
>
>
>* table HATCINFO
>
>* hi_chicks	hi_htchpct	hi_eggprice
>* 9101		.8618			2.30	
>* 42413		.8033			1.95
>
>
>SELECT hi_chicks / hi_htchpct as eggs, ;
>hi_eggprice ;
>FROM it!hatcinfo ;
>WHERE hi_invnum = 'A0017' ;
>AND !DELETED() ;
>INTO CURSOR curs1
>
>SELECT SUM(eggs) as sqTotalEggs, SUM(hi_eggprice * eggs) as sqTotalAmt ;
>FROM curs1 ;
>into CURSOR curs2
>
>lnAggregatePrice = sqTotalAmt / sqTotalEggs
>
>? lnAggregatePrice
>
>
>The lnAggregatePrice should equal 2.01.
>
>Thanks!
>
>Yossi
SET DELETED ON

SELECT ;
   SUM(hi_chicks / hi_htchpct *hi_eggprice)/SUM(hi_chicks / hi_htchpct) AS lnAggregatePrice ;
,  SUM(hi_chicks / hi_htchpct) as sqTotalEggs ;
,  SUM(hi_chicks / hi_htchpct*hi_eggprice) as sqTotalAmt ;
FROM it!hatcinfo ;
WHERE hi_invnum = 'A0017' ;
into CURSOR RESULTS

? lnAggregatePrice 
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform