1、過濾重復(fù)行 select distinct 字段 from 表明
站在用戶的角度思考問題,與客戶深入溝通,找到蛟河網(wǎng)站設(shè)計(jì)與蛟河網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、主機(jī)域名、網(wǎng)站空間、企業(yè)郵箱。業(yè)務(wù)覆蓋蛟河地區(qū)。
2、查找重復(fù)行 select 字段 ,count(*) from group by 字段 having count(*)1
1、查出表中重復(fù)列的數(shù)據(jù):
select a,count(*) from table group by a having count(*)1
2、查重復(fù)次數(shù)最多的列:
select a,num from (
select a,count(*) ?num from table group by a having count(*)1
)
order by num desc
此外,還有
1、查詢一個(gè)表中所有字段都相同的記錄
比如現(xiàn)在有一人員表?? (表名:peosons)
若想將姓名、編號、住址這三個(gè)字段完全相同的記錄查詢出來:
select ?p1.* ?from ?persons ?p1,persons ?p2 ?where ?p1.name=p2.name ?and ?p1.id = ?p2.id ?and ?p1.address=p2.address ? ? ? ? ? ? ? ? ?group by p1.name,p1.id,p1.address ?having count(*) 1;
或者:
select ?p1.* ?from ?persons ?p1,persons ?p2 ?where ?p1.name=p2.name
and ?p1.id=p2.id ?and ?p1.address=p2.address ?and ?p1.rowidp2.rowid;
或者:(下面這條語句執(zhí)行效率更高)
select ?* ?from (select ?p.*,row_number() ?over ?(partition ?by ?name,
id,address ?order ?by ?name) ?rn ?from ?persons ?p) ?where ?rn1;
2、 查詢一個(gè)表中某字段相同的記錄
語法:select ?p1.* ?from ?表名 p1,(select ?字段 ?from ?表名 group ?by ?字段 ?having ?count(*)1) ?p2 ?where ?p1.字段=p2.字段;
select ?p1.* ?from ?persons ?p1,(select ?address ?from ?persons ?group ?by ?address ?having ?count(*)1) ?p2
where ?p1.address=p2.address;
3、查詢一個(gè)表中某字段相同的記錄,其它字段不用查詢出來
select ?name,count(*) ?from ?persons group ?by ?name ?having ?count(*) 1;
用 distinct 屬性,在select之后加distinct
例:
select distinct *
from table;
select distinct name,age
from table
where 條件;
select col1,col2,count(*)
from tab_1
group by col1,col2
having count(*) 1;
查出來重復(fù)數(shù)據(jù)了
然后
delete tab_1 a where rowid in (
select max(rowid) from tab_1 b
where a.col1=b.col1
and a.col2=b.col2
);
OK,搞定!
記住了,刪除之前一定要先備份,在查詢是不是要?jiǎng)h除的數(shù)據(jù),然后再刪除。
網(wǎng)站標(biāo)題:oracle如何去重復(fù)列,oracle如何找出重復(fù)的列名
文章網(wǎng)址:http://chinadenli.net/article8/heccip.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)、用戶體驗(yàn)、ChatGPT、微信公眾號、云服務(wù)器、面包屑導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)