select spno,sum(case when type<3 then 1 else 0 end),
sum(case when type >=3 then 1 else 0 end),sum(1)
from yourTable
group by spno;
sum(case when type >=3 then 1 else 0 end),sum(1)
from yourTable
group by spno;
解决方案 »
- 电脑装了精简版9I和ORACLE 10客户端
- 求助!!!Oracle与C中数据类型对应关系?
- 谁来帮帮我 ORA-00936:missing expression 错误。
- 关于登陆oms的问题,请高手帮助,谢谢.
- 请教LINUX下ORACLE的恢复问题?
- 求救:本人在linux下oracle10G数据库中用"exp"导出备份出现一下错误。请教高手指导........
- BFILE类型字段的使用
- 自动启动oracle数据库
- 安装oracle8i后,每次起win都出现错误提示 !!!!
- 关于Oracal OLE DB?的下载和安装。
- 本菜鸟有一个sql问题,请高手赐教,感激万分。急~~~~
- 带条件的触发器
sum(decode(sign(type-3),-1,0,1) 'type>=3',
sum(1) 'type总个数'
group by spno;
spno,
(select count(*) from e where type<3 and e.spno=xx.spno) "TYPE<3(个数)",
(select count(*) from e where type>2 and e.spno=xx.spno) "TYPE>=3(个数)",
(select count(*) from e where e.spno=xx.spno) "TYPE(总个数)"
from e xx group by spno;
sum(decode(sign(TYPE-3),0,1,1,1,0)),count(TYPE)
from tablename
group by SPNO 对你有帮助是我最大的快乐
sum(decode(sign(type-3),-1,0,1)) "TYPE>=3(个数)",
sum(1) "TYPE(总个数)" from sn_type
group by spno;