Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
More than one value needed
Message
De
10/02/2006 16:14:56
 
 
À
10/02/2006 14:50:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01095537
Message ID:
01095562
Vues:
16
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform