Subject RE: [firebird-support] SELECT GROUP BY
Author sab
Replace GROUP BY
CL.QUANTITE,CL.PRIX_UNITAIRE,CL.TAUX_REMISE,CL.TAUX_TVA,CL..COMMANDE_ID
By
GROUP BY CL.COMMANDE_ID


Provenance : Courrier pour Windows 10

De : m_brahim11@... [firebird-support]
Envoyé le :lundi 25 décembre 2017 21:09
À : firebird-support@yahoogroups.com
Objet :[firebird-support] SELECT GROUP BY

 
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 foreign 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 ?
 




[Non-text portions of this message have been removed]