ORACLE查询某一字段重复的数据

转自:http://www.cnblogs.com/zrui-xyu/p/4566079.html


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

结果如下:

第二种方法:

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 * 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 datetimegroup by m.datetime
having count(m.datetime) > 1
)


你可能感兴趣的:(数据库)