Subject | Why won't this query work? |
---|---|
Author | dixonepperson |
Post date | 2003-05-19T19:14:50Z |
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. There is only one matching
result set for CO_name, all the a.ADR_xxx have only one matching
result set and there is only one p.PO_xxx. however there are several
d.PD_xxx which is the detail table.
Dixon
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. There is only one matching
result set for CO_name, all the a.ADR_xxx have only one matching
result set and there is only one p.PO_xxx. however there are several
d.PD_xxx which is the detail table.
Dixon