Subject | Re: [firebird-support] Select - problem with Group by |
---|---|
Author | Helen Borrie |
Post date | 2004-12-19T01:50:24Z |
At 08:52 PM 18/12/2004 +0000, you wrote:
see where you are going!! It also makes it *much* easier when using
replaceable parameters, since these apply to WHERE criteria and never to
joining criteria.
Also take care to alias everything properly (alias was missing from
DATE_RECUE so I'm guessing here).
SELECT
B.CODE_PROD ,
SUM(B.QTE_RECUE_ENT)
FROM
RECEPTION_MARCHANDISE_MAITRE A
join RECEPTION_MARCHANDISE B
on A.NO_RECEPTION=B.NO_RECEPTION_MAITRE
join Produit P
on B.Code_Prod = P.Code_Prod
where
b.DATE_RECUE='2004-12-17'
AND A.VALIDER='O'
AND A.NO_SUCC=3
and P.Actif = 'Y'
GROUP BY B.CODE_PROD
./heLen
>SELECTFirst, use the SQL-92 explicit join syntax as it makes it much clearer to
>B.CODE_PROD ,
>SUM(B.QTE_RECUE_ENT)
>
>FROM
>RECEPTION_MARCHANDISE_MAITRE A,
>RECEPTION_MARCHANDISE B
>
>where
>A.NO_RECEPTION=B.NO_RECEPTION_MAITRE
>AND DATE_RECUE='2004-12-17'
>AND A.VALIDER='O'
>AND A.NO_SUCC=3
>GROUP BY B.CODE_PROD
>
>-----------
> >From this, i want only B.CODE_PROD showing ACTIF='Y' from table
>PRODUIT C to show. (Note: CODE_PROD are identical in both PRODUIT and
>RECEPTION_MARCHANDISE tables). I have found no way to add this filter
>to the existing script. Any one have an idea?
see where you are going!! It also makes it *much* easier when using
replaceable parameters, since these apply to WHERE criteria and never to
joining criteria.
Also take care to alias everything properly (alias was missing from
DATE_RECUE so I'm guessing here).
SELECT
B.CODE_PROD ,
SUM(B.QTE_RECUE_ENT)
FROM
RECEPTION_MARCHANDISE_MAITRE A
join RECEPTION_MARCHANDISE B
on A.NO_RECEPTION=B.NO_RECEPTION_MAITRE
join Produit P
on B.Code_Prod = P.Code_Prod
where
b.DATE_RECUE='2004-12-17'
AND A.VALIDER='O'
AND A.NO_SUCC=3
and P.Actif = 'Y'
GROUP BY B.CODE_PROD
./heLen