昊天

ORACLE 行转列

select t.task_id,
       max(decode(t.ps_org_no, '35406', t.value)) a,
       max(decode(t.ps_org_no, '3540601', t.value)) b,
       max(decode(t.ps_org_no, '3540602', t.value)) c,
       max(decode(t.ps_org_no, '3540603', t.value)) d
from s_csqe_eva_rslt t
where t.task_id = '28884'
   and t.content_id = '24730'
group by t.task_id;

 
删除重复值

方法二: delete from demo where rowid in
(select rid from
(select rowid rid,row_number() over(partition by object_id order by rowid) rn
from demo)
where rn <> 1 );
耗时:30秒

方法三: create table demo2 as
select object_id,owner... from
(select demo.*,row_number() over(partition by object_id order by rowid) rn from demo)
where rn = 1;
truncate table demo; insert into demo select * from demo2; drop table demo2;
共耗时: 10秒,适合大数据量的情况,产生更少回滚量;

 

posted on 2011-03-14 09:54 昊天 阅读(564) 评论(0)  编辑  收藏 所属分类: oracle


只有注册用户登录后才能发表评论。


网站导航:
 

导航

<2011年3月>
272812345
6789101112
13141516171819
20212223242526
272829303112
3456789

统计

留言簿(1)

随笔分类

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜