Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Elegant SQL
Message
From
11/05/2005 12:12:08
 
 
To
11/05/2005 11:45:17
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01012923
Message ID:
01012947
Views:
22
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 
Previous
Reply
Map
View

Click here to load this message in the networking platform