Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
More than one value needed
Message
From
10/02/2006 16:14:56
 
 
To
10/02/2006 14:50:51
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01095537
Message ID:
01095562
Views:
14
>Hi,
>
>3 tables with some data.
>
>head table :
>batchno
>11111
>22222
>33333
>44444
>
>detail table:
>batchno price
>11111 100.00
>11111 200.00
>22222 222.00
>22222 333.00
>33333 444.00
>33333 555.00
>44444 666.00
>44444 777.00
>44444 888.00
>
>taxes table:
>batchno taxes
>11111 10.00
>11111 20.00
>
>22222 22.20
>22222 33.30
>
>33333 44.40
>33333 55.50
>
>44444 66.60
>44444 77.70
>44444 88.80
>
>The output would be as :
>
>batchno subtotal taxes grandtotal
>11111 300.00 30.00 330.00
>22222 555.00 55.50 610.50
>.............................
>
>Tia
SELECT head.batchno  
, SUM(detail.price)  subtotal 
, SUM(taxes.taxes) taxes 
, SUM(detail.price) + NVL(SUM(taxes.taxes),0) grandtotal
FROM head 
  LEFT JOIN detail ON detail.batchno  = head.batchno 
  LEFT JOIN taxes ON taxes.batchno  = head.batchno 
GROUP BY 1
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform