ORACLE中查询同一字段重复出现的数据!

第一种方法:code

select a.*  
    from ASSET_MAINTAIN a
    inner join ASSET_MAINTAIN b
    on a.asset_id = b.asset_id
    and a.rowid != b.rowid

第二种方法:date

select *
  from ASSET_MAINTAIN n
 where n.asset_id in (select m.asset_id
                        from ASSET_MAINTAIN m 
                       group by m.asset_id 
                      having count(m.asset_id) > 1)

由于有一处processinstanceid是同样的,因此后者合并了数据select

示例:方法

select * from thunder n where n.datetime in (
select m.datetime from thunder2014 m where datetime>to_date('2017-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss') 
and datetime<to_date('2018-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss')
group by m.datetime
having count(m.datetime) > 1
)