解决方案 »
- 一个oracle数据统计的问题
- mysql 存储过程 转换为Sql Server 2005 数据库存储过程写法
- SQL语句格式变换为ORACAL时碰到困难,SOS
- 一个sql语句,急需帮忙!
- Sql和Oracle存储过程 大虾国庆帮忙
- 关于Oracle数据库密码文件创建的问题!急!!!
- 进SQL*PLUS时,提示错误:ORA-01033: ORACLE initialization or shutdown in progress
- 数据库检索速度
- 为何我的sql load不能用?
- Oracle卸载之后为什么有些文件无法删除?高分相送!
- 如何把一个字段中2个下划线中的字符取出来?多谢
- 大哥,大姐帮帮忙,小弟这里有个关于utl_file的问题。
select count(1)-count(case when status = 1 then 1 else null end)
from order
;
when status = '01' then
1
else
0
end)
from order;
with t as
(
select '01' id,'aaa' name,'01' status from dual
union all
select '02' id,'aba' name,'02' status from dual
union all
select '01' id,'aaa' name,'01' status from dual
)
select tab1.a - tab2.b
from (select count(1) a from t) tab1,
(select count(1) b from t where t.status = '01') tab2
--查询 总记录数和 status 为 ‘01’ 且 name 是 ‘aaa’,的记录数之差
select count(1)-sum(case when status = '01' and name = 'aaa' then 1 else 0 end)
from order;-- 查询 总记录数和 status 为 ‘01’ 或者 ‘03’ 的记录数之差
select count(1)-sum(case when status in ('01','03') then 1 else 0 end)
from order;
select
from order
where nvl(status,0)<>'01'
(
select '01' id,'aaa' name,'01' status from dual
union all
select '02' id,'aba' name,'02' status from dual
union all
select '01' id,'aaa' name,'01' status from dual
)
SELECT DISTINCT tab.status, COUNT(0) OVER() - COUNT(0) OVER(PARTITION BY status) FROM tab---------------------------
status 记录数之差
01 1
02 2