Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
rjackman1959
Yak Posting Veteran
60 Posts |
Posted - 2009-01-26 : 12:37:26
|
| I know this is simple, but I just can’t figure it out. I am trying to select a list of employees 401K contributions along with their total hours and pay. This is giving me the following error. Any help would be appriciated. Thanks in advanceMsg 8120, Level 16, State 1, Procedure get_401K, Line 5Column 'table00100.EMPLOYID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.select s.socscnum, s.lastname, s.frstname, sum(d.uprtrxam), --401K amount (select sum(untstopy) from table30300 as d1 where d1.employid = s.employid and d1.chekdate = @paypreiod and d1.pyrlrtyp = '1') -–Hours worked --sum(d1.uprtrxam) -– Total Pay – I would like to do the same for payfrom table30300 as d left join table00100 as s on d.employid = s.employidwhere d.chekdate = @paypreiod and d.payrolcd = '401K' and d.chekdate = @paypreiodgroup by s.socscnum, s.lastname, s.frstname, d.employidorder by d.employid |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-01-26 : 12:55:35
|
[code]select s.socscnum, s.lastname, s.frstname, SUM(d.uprtrxam), SUM(CASE WHEN d.pyrlrtyp = '1' THEN s.untstopy ELSE 0 END), SUM(CASE WHEN d.pyrlrtyp = '1' THEN s.uprtrxam ELSE 0 END)FROM table30300 AS dLEFT JOIN table00100 AS s ON s.employid = d.employidWHERE d.chekdate = @paypreiod AND d.payrolcd = '401K' AND d.chekdate = @paypreiodGROUP BY s.socscnum, s.lastname, s.frstname, d.employidORDER BY d.employid[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
rjackman1959
Yak Posting Veteran
60 Posts |
Posted - 2009-01-26 : 14:16:47
|
| You are always there for me Peso. I guess I was trying to over think it. Thank You ver much |
 |
|
|
|
|
|
|
|