Please read
http://www.dbonline.cn/source/oracle/20031215/BACKUP_transposing%20a%20table%
20into%20a%20summary%20matrix.html
http://www.dbonline.cn/source/oracle/20031215/BACKUP_transposing%20a%20table%
20into%20a%20summary%20matrix.html
解决方案 »
- 多个点之间的距离如何建表
- 有cognos商业智能的中文教程或视频吗?
- ORA-00932: 不一致的数据类型: 要求 - 得到的却是 BLOB
- 数据库报错,不知道具体是什么原因
- 急!使用客户端连接上Oracle10g数据库的问题??(我是初学者)顶者有分!!不行再加分
- oracle9i里,我无法insert进去中文
- 怎么修改windows2000一次I/O缓冲的大小.
- ●●●●oracle8.05中怎么能增加MAXOPENCURSORS. (找不到INIORA文件)●●●
- 机器安装了Oracle8.05,卸载后安装8.16,安装过程正常,但不能启动服务OracleOraHome81ManagementServer,请高手指点
- 高分请教,如何生成计划任务???
- 难道Oracal中的这些表格都不存在吗?
- 高分求助...简单SQL语句查询
select count(*) from feedback_info
where serial_id in (
select serial_id from customer_feedback
where fb_time>to_date('20040601','yyyymmdd') and fb_time<to_date('20040701','yyyymmdd') and fb_type='1' and fb_subtype1<>'T') and khpp='0' ) as qqt,
(select count(*) from feedback_info
where serial_id in (
select serial_id from customer_feedback
where fb_time>to_date('20040601','yyyymmdd') and fb_time<to_date('20040701','yyyymmdd')
and fb_type='1' and fb_subtype1<>'T') and khpp='2' ) as dgdd,
(select count(*) from feedback_info
where serial_id in (
select serial_id from customer_feedback
where fb_time>to_date('20040601','yyyymmdd') and fb_time<to_date('20040701','yyyymmdd')
and fb_type='1' and fb_subtype1<>'T') and khpp='1' ) as szx,
(select count(*) from feedback_info
where serial_id in (
select serial_id from customer_feedback
where fb_time>to_date('20040601','yyyymmdd') and fb_time<to_date('20040701','yyyymmdd')
and fb_type='1' and fb_subtype1<>'T' ) and khpp in('3','4' )) as dfpp
from dual
union
select '到达数' as xm,(
select count(*) from feedback_info
where serial_id in (
select serial_id from customer_feedback
where fb_time>to_date('20040601','yyyymmdd') and fb_time<to_date('20040701','yyyymmdd')
and fb_type='1' and fb_subtype1<>'T' and deal_status='H') and khpp='0' ) as qqt,
(select count(*) from feedback_info
where serial_id in (
select serial_id from customer_feedback
where fb_time>to_date('20040601','yyyymmdd') and fb_time<to_date('20040701','yyyymmdd')
and fb_type='1' and fb_subtype1<>'T' and deal_status='H') and khpp='2' ) as dgdd,
(select count(*) from feedback_info
where serial_id in (
select serial_id from customer_feedback
where fb_time>to_date('20040601','yyyymmdd') and fb_time<to_date('20040701','yyyymmdd')
and fb_type='1' and fb_subtype1<>'T' and deal_status='H') and khpp='1' ) as szx,
(select count(*) from feedback_info
where serial_id in (
select serial_id from customer_feedback
where fb_time>to_date('20040601','yyyymmdd') and fb_time<to_date('20040701','yyyymmdd')
and fb_type='1' and fb_subtype1<>'T' and deal_status='H') and khpp in('3','4' ))as dfpp
from dual;
--从临时表取你要的数据
select (case khpp when 0 then count(*)0 when 1 then count(*)1 when 2 then count(*)2 when 3 then count(*)3 when 4 then count(*)4 ) from t#
临时表:能不能这样我用的时候创建,不用的时候删除,如果这样,那么频繁的操作会对数据库有影响的。
0 82
1 54
2 150
3 1244
4 231select
sum(col0) col0,
sum(col1) col1,
sum(col2) col2,
sum(col3) col3,
sum(col4) col4
from
(
select
decode(a.khpp,0,a.ct,0) col0,
decode(a.khpp,1,a.ct,0) col1,
decode(a.khpp,2,a.ct,0) col2,
decode(a.khpp,3,a.ct,0) col3,
decode(a.khpp,4,a.ct,0) col4
from
tablename a
)
create table t# as select khpp,count(*) count from feedback_info
where serial_id in (
select serial_id from customer_feedback
where fb_time>to_date('20040601','yyyymmdd') and fb_time<to_date('20040701','yyyymmdd') and fb_type='1' and fb_subtype1<>'T') group by khpp;--从临时表取出数据select (case khpp when 0 then count 0 when 1 then count 1 when 2 then count 2 when 3 then count 3 when 4 then count 4 ) from t#--删除临时表drop table t#;