oracle查询时不重复,oracle查询不重复数据详解

方法一:

select jqbh,cjdbh,sjybh,sjyxm from (select t.jqbh,t.cjdbh,t.sjybh,t.sjyxm,row_number() OVER(PARTITION BY t.sjybh ORDER BY t.jqbh) ds from T_ITMP_TCS_DISPOSAL t

where t.sjyxm is not null)

where ds=1

方法二:

select jqbh,cjdbh,sjybh,sjyxm

from T_ITMP_TCS_DISPOSAL

where cjdbh in(select min(cjdbh) from T_ITMP_TCS_DISPOSAL WHERE sjyxm is not null group by sjybh);

结果集:

fff6c98081bf8904098fb5e1bd59ff4b.gif

参考:

--去重查询方法一:根据id

select * from sxe where id in(select min(id) from sxe group by username) order by id asc;

--去重查询方法二:根据rownum

select * from (select s.*,rownum rn from sxe s ) x where x.rn in (select min(rownum) from sxe group by username) order by id asc;

--去重查询方法三:


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部