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 |
SQLNEWBIZ
Starting Member
27 Posts |
Posted - 2013-04-01 : 11:25:05
|
Hello All,Can anyone please correct the following query,SELECT e.e_id ,e.fname , Sum (ot.OTHours ) as Tothours,ot.chargesperhour,ot.DateofOT,ot.Payment_Status from employee e inner join OvertimeRecord ot ON ot.E_ID=e.e_id GROUP BY e.e_id ,e.fname the error showing is:Column 'OvertimeRecord.ChargesPerHour' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.I am a bit new to these.Thanks In Advance. |
|
sanjnep
Posting Yak Master
191 Posts |
Posted - 2013-04-01 : 11:28:16
|
Do like this ....SELECT e.e_id ,e.fname ,ot.chargesperhour,ot.DateofOT,ot.Payment_Status, Sum (ot.OTHours ) as Tothours from employee e inner join OvertimeRecord ot ON ot.E_ID=e.e_id GROUP BY e.e_id ,e.fname, ot.chargesperhour,ot.DateofOT,ot.Payment_StatusSanjeev Shrestha12/17/1971 |
|
|
SQLNEWBIZ
Starting Member
27 Posts |
Posted - 2013-04-01 : 11:33:52
|
Hello,Sanjeev,Thankyou..It worked.. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-04-01 : 13:07:28
|
those two queries are not equivalent. you'll get completely different resultset when you add those additional columns. Dont know what exactly OP was looking at------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|