PL/SQL错误数据的清理

--删除重复数据只留一条

delete from t_kpi_province_m
 where id not in (select max(id) from t_kpi_province_m t group by t.指标)

--删除重复数据

delete from t_kpi_province_m
 where id not in
       (select (id)
          from (select max(id) as id, t.城市, t.类型, t.日期, t.指标
                  from t_kpi_city_d t
                 where to_char(t.日期, 'yyyy-mm-dd') = '2012-09-10'
                 group by t.城市, t.类型, t.日期, t.指标
                 order by t.指标))

--删除重复数据取小时删除

select *
  from t_kpi_city_d t
 where t.指标 = 'GSM半速率比例(本月)'
   and to_char(t.日期, 'yyyy-mm-dd') = '2012-09-10'
   and to_char(t.创建日期, 'hh24') = '11';

 

 

 

posted @ 2012-09-11 13:53  Mr-sniper  阅读(249)  评论(0编辑  收藏  举报