Subject Re: Why won't this query work?
Author dixonepperson
--- In ib-support@yahoogroups.com, "Alexander V.Nevsky" <ded@h...>
wrote:
> --- In ib-support@yahoogroups.com, "dixonepperson"
<edepperson@j...>
> wrote:
> > 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,
invalid
> > column reference when I try to run.
>
> Dixon, you should group by _all_ non-aggregate column, it is SQL
> standard.
>
> Best regards, Alexander.

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