新的起点 新的开始

快乐生活 !

使用Oracle SQL 删除重复记录及分页 备案

bank_holidays 表结构
desc bank_holidays
Name                           Null     Type                                                                                                                                                                                         
------------------------------ -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BANK_HOLIDAY_ID                NOT NULL NUMBER                                                                                                                                                                                       
BANK_HOLIDAY_DESC                       VARCHAR2(255)                                                                                                                                                                                
BANK_HOLIDAY_DATE                       DATE                                                                                                                                                                                         

3 rows selected

 

分页:

select * from (
select * from bank_holidays where rownum<=5) where bank_holiday_id not in
(select bank_holiday_id from bank_holidays where rownum<=3)


删除重复数据:

delete bank_holidays where bank_holiday_id in(


select bank_holiday_id from bank_holidays where bank_holiday_date in
(
select  bank_holiday_date from bank_holidays  GROUP BY bank_holiday_desc, bank_holiday_date  having count (bank_holiday_desc) >= 2
)and
bank_holiday_id not in (
select min(bank_holiday_id) from bank_holidays  GROUP BY bank_holiday_desc, bank_holiday_date  having count (bank_holiday_desc) >= 2
)

)

 

posted on 2009-04-18 17:11 advincenting 阅读(390) 评论(0)  编辑  收藏 所属分类: 数据库相关


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


网站导航:
 

公告

Locations of visitors to this page

导航

<2009年4月>
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

统计

常用链接

留言簿(13)

随笔分类(71)

随笔档案(179)

文章档案(13)

新闻分类

IT人的英语学习网站

JAVA站点

优秀个人博客链接

官网学习站点

生活工作站点

最新随笔

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜