select count (1) [count] where flag=1
union all
select count (1) where flag=2
union all
select count (1) where flag=3
union all
select count (1) where flag=2
union all
select count (1) where flag=3
解决方案 »
- sql急。。。。。
- 大家帮我看一下这个存储过程那里错了。
- 求一个简单的SQL语句写法
- 动态SQL语句,错在那里??
- 创建用户的问题
- ms sql6.5的登录用户的问题
- 为什么用户查自己的表还要加前缀?
- reporting service 连接问题? 请各位高人务必救我,这个问题让我伤心很久了!
- 我在2000 SERVER上安装SQL Server7.0总是失败,为什么呢?很着急!!!
- EXEC sp_executesql 语法老是有错误,真的是疯了,不知道如何去改
- sqlserver存储过程字符串转换datetime疑惑?
- 别人给了我他的ip地址 和账号 密码,怎么才能用我的电脑登陆他的mysql数据库??
FROM T
select sum(case when flag=1 then 1 else 0 end) 'flag1_qty',
sum(case when flag=2 then 1 else 0 end) 'flag2_qty',
sum(case when flag=3 then 1 else 0 end) 'flag3_qty'
from [表名]
where [条件]