Subject | Re: [firebird-support] SELECT GROUP BY |
---|---|
Author | livius |
Post date | 2017-12-26T15:51:15Z |
Hi all,
SELECT
CAST( COALESCE(CL.QUANTITE * CL.PRIX_UNITAIRE,0) AS NUMERIC(9,2)) AS TOTAL_HT,
SUM(CAST(CL.QUANTITE * CL.PRIX_UNITAIRE *( COALESCE(CL.TAUX_REMISE,0)/100.0) AS NUMERIC(9,2))) AS TOTAL_REMISE, SUM((CL.QUANTITE * CL.PRIX_UNITAIRE) - CL.QUANTITE * CL.PRIX_UNITAIRE * (COALESCE(CL.TAUX_REMISE,0)/100.0)) AS TOTAL_HT_NET,
SUM((COALESCE(CL.TAUX_TVA,0)/100.0)*CL.QUANTITE * CL.PRIX_UNITAIRE*(1.0-(COALESCE(CL.TAUX_REMISE,0)/100.0))) AS TOTAL_TVA,
SUM(CL.QUANTITE * CL.PRIX_UNITAIRE*(1.0-COALESCE(CL.TAUX_REMISE,0)/100) *(1+COALESCE(CL.TAUX_TVA,0)/100.0)) AS TOTAL_TTC
FROM COMMANDE_FOUR_LIGNE CL WHERE CL.COMMANDE_ID=1
GROUP BY
CL.QUANTITE,CL.PRIX_UNITAIRE,CL.TAUX_REMISE,CL.TAUX_TVA,CL.COMMANDE_ID
I need to sum records which have the same foreig n key value (CL.COMMANDE_ID=1) in order to obtain only one line of the fields I sum. The table contains 4 records and I get 4 four records instead of one record. Is that something wrong with my query,can you please help me ?
Ta wiadomość została sprawdzona na obecność wirusów przez oprogramowanie antywirusowe Avast.
|