Click here to Skip to main content
15,908,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Iam use this Procedure but see this error

SQL
Msg 116, Level 16, State 1, Procedure P_Course_Get_Statistics_Summary, Line 45
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.


SQL
alter Procedure  [dbo].[P_Course_Get_Statistics_Summary]

  AS
Begin
    
     select 
	
	  (select Count(*) from TCourse) as Totalcours,
	
	  (select Count(*) from TCourseExe  ) as TotalcoursExe,

	
	(select  count(*)  from
	  (
	    SELECT  [FCourseID]  FROM    [dbo].[TCourse]
				    EXCEPT 
	    SELECT  [FCourseID]   FROM    [dbo].VDB_CoursExe 
       ) temp
    ) as  coursecount ,
			
   
	 (select Count(*) from TCourse where Fsyllabinary is not null) as Issyllabinary,

	
	--• در کل دورها تعریف شده نام و شناسه دوره با ماکزیمم ساعت :
		(select *  from 
		(select FCourseID , FCourseName ,FCourseDuration
			 from  TCourse
			     where FCourseDuration in 
				            (select  MAX(FCourseDuration) as dd from TCourse )	 
		 )  T
		) AS DD

   )  


	 
	        
	 
end
Posted

1 solution

you cannot get multiple columns from a single subquery have to change your query like this

SQL
 ----------- not a valid statement in sub query
(select *  from 
(select FCourseID , FCourseName ,FCourseDuration
		from  TCourse
			where FCourseDuration in 
				    (select  MAX(FCourseDuration) as dd from TCourse )	 
	)  T
) AS DD
 
) 


 -----------  This is the valid formation
(select FCourseID 
		from  TCourse
			where FCourseDuration in 
				    (select  MAX(FCourseDuration) as dd from TCourse )	 
)  T AS FCourseID

(select FCourseName 
		from  TCourse
			where FCourseDuration in 
				    (select  MAX(FCourseDuration) as dd from TCourse )	 
)  T AS FCourseName,

(select FCourseDuration 
		from  TCourse
			where FCourseDuration in 
				    (select  MAX(FCourseDuration) as dd from TCourse )	 
)  T AS FCourseDuration


hope it helps
 
Share this answer
 
Comments
saeed1364 28-Jan-15 7:55am    
thanks
Umer Akram 28-Jan-15 8:00am    
glad to help you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900