March 3, 2009 at 3:30 pm
Oh SQL guru's what have i done wrong ?
SELECT DISTINCT a.EMPLOYID, a.LASTNAME, a.FRSTNAME, a.SOCSCNUM, a.BRTHDATE, a.GENDER,
a.LOCATNID, a.STRTDATE, a.EMPLOYMENTTYPE, a.LASTDAYWORKED_I, b.PAYRTAMT,
c.CHEKDATE, c.UNTSTOPY, c.UPRTRXAM, d.ZIPCODE,
SUM (c.UPRTRXAM) as Gross_Pay
FROM UPR00100 as a
INNER JOIN UPR00400 as b
ON a.EMPLOYID = b.EMPLOYID
INNER JOIN UPR30300 as c
ON a.EMPLOYID = c.EMPLOYID
and PYRLRTYP = '1'
INNER JOIN UPR00102 as d
ON a.EMPLOYID = d.EMPLOYID
where UNTSTOPY != '0'
GROUP BY a.EMPLOYID,a.LASTNAME
March 3, 2009 at 3:44 pm
if you use GROUP BY, then every column that is not using a SUM() or AVG() or other grouping operation MUST be in the GROUP BY Statement...so your query would need this grouping:
GROUP BY a.EMPLOYID,
a.LASTNAME ,
a.FRSTNAME,
a.SOCSCNUM,
a.BRTHDATE,
a.GENDER,
a.LOCATNID,
a.STRTDATE,
a.EMPLOYMENTTYPE,
a.LASTDAYWORKED_I,
b.PAYRTAMT,
c.CHEKDATE,
c.UNTSTOPY,
c.UPRTRXAM,
d.ZIPCODE,
Lowell
March 3, 2009 at 8:02 pm
I can show you a little performance trick (big one, actually) but I need to know which table the following column is in...
and [font="Arial Black"]PYRLRTYP [/font]= '1'
--Jeff Moden
Change is inevitable... Change for the better is not.
March 4, 2009 at 7:57 am
The PYRLRTYP is on the UPR30300 table. Thank You !!! 🙂
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply