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

Click here to load this message in the networking platform