select specialityname ,defecttype ,count(*),
(select count(*) from detable a where a.dispeled=1 and a.specialityname = detable.specialityname and a.defecttype = detable.defecttype ) as tt,
(select count(*) from detable b where b.dispeled=1 and b.specialityname = detable.specialityname and b.defecttype = detable.defecttype ) as ss
from detable group by specialityname,defecttype
(select count(*) from detable a where a.dispeled=1 and a.specialityname = detable.specialityname and a.defecttype = detable.defecttype ) as tt,
(select count(*) from detable b where b.dispeled=1 and b.specialityname = detable.specialityname and b.defecttype = detable.defecttype ) as ss
from detable group by specialityname,defecttype
解决方案 »
- 怎样将查询的所有数据,一次插入已存在的一个表
- 请教一下这个通过游标获得指定行咋不执行呢?
- **********************请教一个函数使用问题********************
- 紧急求sql: 日期以“YYYY-MM-DD”格式保存在一个字符型字段中。如何取出今天的所有记录?getdate 和 now 我没办法格式化呀!
- 如何只对数据库中一个表进行备份和还原操作?
- SQL2005里面的乱码如何解决?
- Insert Into 能同时插两个表吗?
- 急!帮我看看这句SQL有什么问题。。
- 一个表读出两份重复的列记录
- 如何把服务器的内存划给“SQLServer”???
- 在INTERNET上如何隐藏我的SQL SERVER?
- 怎么样才能不让别人删除表中的某几行记录呢??
from detable group by specialityname,defecttype
sum(case when dispeled=1 then 1 else 0 end ) as tt,
sum(case when dispeled=0 then 1 else 0 end ) as ss
from detable
group by specialityname,defecttype
sum(case when dispeled=1 then 1 else 0 end ) as tt,
sum(case when dispeled=0 then 1 else 0 end) as ss
from detable group by specialityname,defecttype