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 |
prashantdighe
Starting Member
21 Posts |
Posted - 2012-05-13 : 23:50:26
|
Hi all I m trying to get all value from same table but on different conditions(using where clause) so tried first column named Session_Taken_by alter PROCEDURE [dbo].[Pivot_Report_Rating_only_Day] (@P_Name Varchar(MAX))AS BEGINdeclare @query1 nvarchar(200)set @query1=(select [Session_taken_By] from Program_rating where Program_name=@P_Name group by Session_taken_By,Session_Title)EXEC sp_executesql @query1endbut it shows following error Msg 512, Level 16, State 1, Procedure Pivot_Report_Rating_only_Day, Line 13Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
prashantdighe
Starting Member
21 Posts |
Posted - 2012-05-13 : 23:57:21
|
Can I use CASE for this purpose???? |
 |
|
prashantdighe
Starting Member
21 Posts |
Posted - 2012-05-14 : 01:01:09
|
Please help!!!!!SELECTContribution,SUM(CASEWHEN Contribution >= 4 AND Contribution <> 10THEN ContributionELSE NULLend) as ContrFROM program_rating where Program_name=@P_name group by Session_taken_By,Session_Titleerror!!!!!Msg 8120, Level 16, State 1, Procedure Pivot_Report_Rating_only_Day, Line 12Column 'program_rating.Contribution' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. |
 |
|
|
|
|
|
|