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 |
|
tariq2
Posting Yak Master
125 Posts |
Posted - 2011-02-22 : 11:24:17
|
| -- So the following query gives me a list of users and the number of times they have used different reportsselect UserName,ReportName,ReportCount from View_BIUsers_ReportData where LEID = '02001' and SBLID = 'MKG'and TreeYear = 2011and Year = 2011---- I want to now group this by username and try the following select UserName,ReportName,sum(ReportCount) from View_BIUsers_ReportData where LEID = '02001' and SBLID = 'MKG' and TreeYear = 2011 and Year = 2011 group by ReportNameand get the following message:Msg 8120, Level 16, State 1, Line 1Column 'View_BIUsers_ReportData.UserName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.So When I try MAX(username) it obviously gives me the user who has used teh report the maximum number of timeswhich is not what I want.Any help is much appreciated |
|
|
tariq2
Posting Yak Master
125 Posts |
Posted - 2011-02-22 : 11:55:37
|
| I have realized what was wrong. Thanks |
 |
|
|
|
|
|