读书人

50分请问这个合计的SQL语句如何写啊

发布时间: 2012-01-11 22:28:46 作者: rapoo

50分请教这个合计的SQL语句怎么写啊????
表中有2个标识字段FIsRead,FIsNotify都是 bit型的

FIsRead FIsFeedback
------- -----------
1 1
0 0
1 1
1 0
0 1
1 0
现在要一起统计FIsRead 为1和FIsFeedback为1的行数
在一个结果集中
FIsRead FIsFeedback
------- -----------
4 3

这个语句怎么写啊?

[解决办法]
select
sum(case FIsRead when 1 then 1 else 0 end) as FIsRead,
sum(case FIsFeedback when 1 then 1 else 0 end) as FIsFeedback
from table

读书人网 >SQL Server

热点推荐