December 14, 2010 at 12:36 am
Hi All,
I'm try to use the below query but actually it gives "Grouping" error
please help what is wrong.
Query:
SELECT dbo.tblUser.UserLoginName, dbo.tblWorkDocu.WorkID, dbo.tblWorkTemp.WorkTempTitle, dbo.tblWorkDocu.LastEditOn
FROM dbo.tblWorkDocu INNER JOIN
dbo.tblUser ON dbo.tblWorkDocu.LastEditBy = dbo.tblUser.UserID LEFT OUTER JOIN
dbo.tblWorkTemp ON dbo.tblWorkDocu.TempID = dbo.tblWorkTemp.WorkTempID
WHERE (DATEDIFF(day, dbo.tblWorkDocu.LastEditOn, GETDATE()) <= 0)
GROUP BY tblUser.UserLoginName,tblWorkTemp.WorkTempTitle
the error is:
Msg 8120, Level 16, State 1, Line 1
Column 'dbo.tblWorkDocu.WorkID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
December 14, 2010 at 1:00 am
As the error says, you have the WorkID column in the select clause but it's not present in the group by. You need to either remove it from the select or add it to the group by.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply