Subject | Re: Why won't this query work? |
---|---|
Author | dixonepperson |
Post date | 2003-05-19T19:32:18Z |
--- In ib-support@yahoogroups.com, "Alexander V.Nevsky" <ded@h...>
wrote:
Thanx but need clarification. . .
do you mean my group by statement should read
GROUP BY p.PO_NUM, c.CO_NAME, a.ADR_ADR1 ... n.DZIP
because they are all non aggregate?
Dixon
wrote:
> --- In ib-support@yahoogroups.com, "dixonepperson"<edepperson@j...>
> wrote:invalid
> > SELECT p.PO_NUM, c.CO_NAME AS VENDOR, a.ADR_ADR1 AS VADR1,
> a.ADR_ADR2
> > AS VADR2,
> > a.ADR_CITY AS VCITY, a.ADR_ST AS VSTATE, a.ADR_ZIP AS VZIP,
> > p.PO_DATE, p.PO_ETA, p.PO_CFM, p.PO_INV, p.PO_TOTAL, p.PO_DISC,
> > p.PO_TAX, p.PO_GTOT,
> > n.DNAME, n.DADR1, n.DADR2, n.DCITY, n.DST, n.DZIP, SUM(d.PD_QTY)
> > FROM POTABLE p
> > LEFT JOIN COMPANY c ON (p.PO_VENID=c.CO_IDNUM)
> > LEFT JOIN ADDRESS a ON (p.PO_VENID=a.ADR_IDNUM AND a.ADR_DEF= 'Y')
> > LEFT JOIN OFFICEPO n ON (p.PO_LOCID=n.DID)
> > LEFT JOIN PODETAIL d ON (p.PO_NUM=d.PD_NUM)
> > WHERE p.PO_NUM='119' GROUP BY p.PO_NUM
> >
> > The issue is with the SUM() function. I get SQL error 104,
> > column reference when I try to run.Alexander,
>
> Dixon, you should group by _all_ non-aggregate column, it is SQL
> standard.
>
> Best regards, Alexander.
Thanx but need clarification. . .
do you mean my group by statement should read
GROUP BY p.PO_NUM, c.CO_NAME, a.ADR_ADR1 ... n.DZIP
because they are all non aggregate?
Dixon