select mc,sum(case when zt=1 then 1 end),Count(zt)
from a inner join b on a.id=b.id
where mc='A1'
group by mc
from a inner join b on a.id=b.id
where mc='A1'
group by mc
解决方案 »
- SQL2000
- sql2005里面的SQLEXPRESS服务
- 关于计算本月的第一个星期一得问题,有点想不明白
- 关键字 'order' 附近有语法错误
- 求一个SQL语句:如何获取一个表中的外建名以及该外键对应的外检表名?
- 关于sqlserver2005 Express 定时删除数据,哪位大侠可以进来指点一下
- sql server支持Rs.MovePrevious!!告诉各位。
- 大侠,有个问题,请教下你哈,现在我知道SQL数据库中的一个库中储存有一个数据“天安门”,但是现在就是不知道这个“天安门”放在哪个物理表里面,能不能通过SQL语句来找到这个数据“天安门”在哪个物理表里面不?谢谢了。还有没有其他的方法吗?
- 如何提高ACCESS的查询速度?
- 返回记录总数! 在SQL SERVER 中过程怎样写?
- sql server id 重置
- ////// 在sqlserver2000中,如何将数字2格式化为字符串'02'
sum(case when a.zt=1 then 1 else 0 end) as [状态为1的],
sum(1) as [所有的]
from a,b
where a.id=b.id
and b.mc='A1'
group by b.mc
sum(case when a.zt=1 then 1 else 0 end) as [状态为1的],
count(1) as [所有的]
from a,b
where a.id=b.id
and b.mc='A1'
group by b.mc