id leixing banzu guoqi shijian
1 A 班组1 T 2011-7-1
2 A 班组2 F 2009-9-1
3 B 班组2 T 2011-8-1
4 C 班组1 F 2011-9-1
在上面的表中,我要得到一组数据:在时间(shijian)2011-7-31前所有记录中,班组1 的过期(guoqi)的记录多少,班组1的 总记录多少, 类型(leixing)A的记录多少,B的记录多少用一条sql能实现吗?
请赐教
1 A 班组1 T 2011-7-1
2 A 班组2 F 2009-9-1
3 B 班组2 T 2011-8-1
4 C 班组1 F 2011-9-1
在上面的表中,我要得到一组数据:在时间(shijian)2011-7-31前所有记录中,班组1 的过期(guoqi)的记录多少,班组1的 总记录多少, 类型(leixing)A的记录多少,B的记录多少用一条sql能实现吗?
请赐教
解决方案 »
- oracle以sysdba身份imp导入时的疑问
- Oracle Developer 2000 怎样屏蔽报表列印功能?
- 针对oracle表操作日志删除
- csdn的搜索功能是不是停掉了?
- 怎么确定关键字的类型
- tuxedo与oracle的数据库连接问题
- 用select max(length(t.mc)) from table t 发现里面数据最大长度为43,但是把mc长度改为50的时候,确提示出错ora-01441错误,某些列长度过长
- oracle RAC 里指的RAW设备是什么?
- 紧急求助:帮我看看一个SQL存储过程,错在什么地方?
- 请教关于pro*c的配置、使用的问题!?<<怪!急!>>
- ORACLE修改字段类型(急)
- 表名作为参数,写一个接口,把数据写到OS文件上
when (banzu = '班组1' and guoqi = 'T') then
1
else
0
end) as col1,
sum(case
when banzu = '班组1' then
1
else
0
end) as col2,
sum(case
when leixing = 'A' then
1
else
0
end) as col3,
sum(case
when leixing = 'B' then
1
else
0
end) ascol4
from table
where sj <= '2011-7-31'
b as (select count(*) from biao where banzu = '班组1')
c as (select count(*) from biao where leixing ='A')
d as (select count(*) from biao where leixing = 'B')
SELECT * FROM A,B,C,D
select count(case when banzu='班组1' and guoqi='T' then 1 end),
count(case when banzu='班组1' then 1 end),
count(decode(leixing,'A',1),
count(decode(leixing,'B',1)
from t
where shijian<to_date('2011-07-31','yyyy-mm-dd')
/
select count(case when banzu='班组1' and guoqi='T' then 1 end)
,count(decode(banzu,'班组1',1)),
,count(decode(leixing,'A',1))
,count(decode(leixing,'B',1))
from t
where shijian<to_date('2011-07-31','yyyy-mm-dd')
/