本文介绍了如何在子查询中使用count的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Msg 512, Level 16, State 1, Procedure usp_GetSummaryReportForCompAdmin, Line 11
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
我收到此错误
I am getting this error
Select COUNT(*) from QualificationDevelopments where AddedForId = e.Id and (DataForYear in (Select DataForYear from QualificationDevelopments))
and Status <> 4
) as TotalDevelopments,
I want the count of all years present in this column. but it is throwing an exception
推荐答案
(Select COUNT(*) from QualificationDevelopments where AddedForId = e.Id and (@DataForYear Is Null or QualificationDevelopments.DataForYear = @DataForYear )) and Status <> 4 ) as TotalDevelopments
这篇关于如何在子查询中使用count的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!