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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Group by Error!!!!

Author  Topic 

prashantdighe
Starting Member

21 Posts

Posted - 2012-05-14 : 00:59:29
Please help!!!!!
SELECT
Contribution,
SUM(CASE
WHEN Contribution >= 4 AND Contribution <> 10
THEN Contribution
ELSE NULL
end) as Contr

FROM program_rating where Program_name=@P_name group by Session_taken_By,Session_Title

error!!!!!

Msg 8120, Level 16, State 1, Procedure Pivot_Report_Rating_only_Day, Line 12

prashantdighe
Starting Member

21 Posts

Posted - 2012-05-14 : 01:00:44
Please help!!!!!
SELECT
Contribution,
SUM(CASE
WHEN Contribution >= 4 AND Contribution <> 10
THEN Contribution
ELSE NULL
end) as Contr

FROM program_rating where Program_name=@P_name group by Session_taken_By,Session_Title

error!!!!!

Msg 8120, Level 16, State 1, Procedure Pivot_Report_Rating_only_Day, Line 12
Column 'program_rating.Contribution' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Go to Top of Page

vijays3
Constraint Violating Yak Guru

354 Posts

Posted - 2012-05-14 : 04:54:02


Please try this


SELECT
---Contribution,
Session_taken_By,
Session_Title
SUM(CASE
WHEN Contribution >= 4 AND Contribution <> 10
THEN Contribution
ELSE NULL
end) as Contr

FROM program_rating where Program_name=@P_name group by Session_taken_By,Session_Title


Vijay is here to learn something from you guys.
Go to Top of Page
   

- Advertisement -