输入banner图图片脚本导航/分类

SQL一次查出多个字段的COUNT值

select 2 count(case when TOFlag=10 or TOFlag=5 then 1 else null end) WaitingPayCount, 3 count(case when TOFlag=15 OR TOFlag=20 then 1 else null end) WaitingTravelCount, 4 count(case when TOFlag=40 and TOIsComment=0 then 1 else null end) WaitingComment 5 from [TGuideOrder] with(nolock)

 

至于SQL Case when 的使用方法,我在网上看到一个比较详细的帖子,就不添足了:Case when 的使用方法

SQL一次查出多个字段的COUNT值

标签: