Oracle去重4種實現(xiàn)方式小結(jié)
去重
1.distinct去重
select distinct name,age from test
2.group by 去重
select name,age from test group by name,age;
3.rowid(偽列去重)如果 step_id 也要要求去重就把條件加上去,如果不需要去重則不加
select sfc_no,step_id from AAA_HC t1 where t1.rowid in (select min(rowid) from AAA_HC t2 where t1.sfc_no=t2.sfc_no --and t1.step_id=t2.step_id );
4.窗口函數(shù)row_number () over() 去重 如果 step_id 也要要求去重就把條件加上去,如果不需要去重則不加
select t.sfc_no ,t.step_id from (select row_number() over(partition by sfc_no --,step_id order by step_id) rank,AAA_HC.* from AAA_HC)t where t.rank = 1;
row_number() over(partition by SFC_NO order by CREATE_DATE desc) rn
為新增一個名為rn的排名的列,partition by 列名(需要分組的列) order by 列名(需要排名的列)
結(jié)果
SFC_NO CREATE_DATE rn aaa 2022-09-22 1 aaa 2022-09-21 2 aaa 2022-09-20 3 bbb 2022-09-22 1 bbb 2022-09-21 2 bbb 2022-09-20 3
總結(jié)
到此這篇關(guān)于Oracle去重4種實現(xiàn)方式的文章就介紹到這了,更多相關(guān)Oracle去重方式內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
基于Oracle的面向?qū)ο蠹夹g(shù)入門基礎(chǔ)簡析開發(fā)者網(wǎng)絡(luò)Oracle
基于Oracle的面向?qū)ο蠹夹g(shù)入門基礎(chǔ)簡析開發(fā)者網(wǎng)絡(luò)Oracle...2007-03-03Oracle 11g安裝錯誤提示未找到wfmlrsvcapp.ear的解決方法
這篇文章主要為大家詳細介紹了Oracle 11g安裝錯誤提示未找到wfmlrsvcapp.ear的解決方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-04-04Oracle expdp/impdp 及 exp/imp 命令詳解
使用Oracle數(shù)據(jù)庫的過程中會經(jīng)常對數(shù)據(jù)進行導(dǎo)入導(dǎo)出,Oracle 數(shù)據(jù)庫提供 expdp / impdp (Data Pump,數(shù)據(jù)泵)以及 exp / imp 兩種工具進行數(shù)據(jù)的導(dǎo)入導(dǎo)出,可以對數(shù)據(jù)庫進行邏輯備份,這篇文章主要介紹了Oracle expdp/impdp 及 exp/imp 命令詳解,需要的朋友可以參考下2024-07-07Oracle數(shù)據(jù)庫中通用的函數(shù)實例詳解
OracleSQL提供了用于執(zhí)行特定操作的專用函數(shù),這些函數(shù)大大增強了SQL語言的功能,下面這篇文章主要給大家介紹了關(guān)于Oracle數(shù)據(jù)庫中通用函數(shù)的相關(guān)資料,需要的朋友可以參考下2022-03-03Oracle數(shù)據(jù)庫中 call 和 exec的區(qū)別
在sqlplus中這兩種方法都可以使用: exec pro_name(參數(shù)1..); call pro_name(參數(shù)1..); 但是這兩者有什么區(qū)別呢?今天小編給大家介紹下oracle數(shù)據(jù)庫中 call 和 exec的區(qū)別,感興趣的朋友一起看看吧2016-09-09常見數(shù)據(jù)庫系統(tǒng)比較 Oracle數(shù)據(jù)庫
常見數(shù)據(jù)庫系統(tǒng)比較 Oracle數(shù)據(jù)庫...2007-03-03