I am getting this error with the following code. I also get the error for column 3 of 'c'
Here is a snapshot of the errors I am getting with this code.
I have updated my SQL below. This is as of 6/5/14
USE SYNLIVE
SELECT
INLOC.Itemkey, l.Description, INLOC.Location, INLOC.Qtyonhand,
sum(l.POqtyRemn) [POqtyRemn],
SUM(c.Qtyord) AS [COqtyOrd], h.Statusflg
FROM
INLOC INLOC
INNER JOIN
(SELECT
POLIN.Itemkey, POLIN.Description, POLIN.Location, POLIN.Pono,
SUM(POLIN.Qtyremn) AS [POqtyRemn]
FROM
POLIN POLIN
GROUP BY
POLIN.Itemkey, POLIN.Description, POLIN.Location, POLIN.Pono) l ON INLOC.Itemkey = l.Itemkey
INNER JOIN
(SELECT
POHDR.Statusflg, POHDR.Pono
FROM
POHDR POHDR
WHERE POHDR.Statusflg = 'NEW' OR POHDR.Statusflg = 'OPEN'
GROUP BY
POHDR.Statusflg, POHDR.Pono) poh ON l.Pono = poh.Pono
JOIN
OELIN c ON INLOC.Itemkey = c.Itemkey
INNER JOIN
(SELECT
OEHDR.Statusflg, OEHDR.Ordno
FROM
OEHDR
WHERE OEHDR.Statusflg = 'NEW' OR OEHDR.Statusflg = 'OPEN'
GROUP BY
OEHDR.Statusflg, OEHDR.Ordno) h ON c.Ordno = h.Ordno
WHERE
((INLOC.Location = 'SPL') AND (l.POqtyRemn > 0)) OR ((INLOC.Location = 'SPL') AND (c.Qtyord > 0))
GROUP BY
INLOC.Itemkey, l.Description, INLOC.Location, h.Statusflg, inloc.Qtyonhand
/* Add other fields that you are pulling -- you must group by all fields (or have a calc on them .. i.e. Sum(field) */
ORDER BY INLOC.Itemkey