婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > SQL Server數(shù)據(jù)庫刪除數(shù)據(jù)集中重復(fù)數(shù)據(jù)實例講解

SQL Server數(shù)據(jù)庫刪除數(shù)據(jù)集中重復(fù)數(shù)據(jù)實例講解

熱門標簽:如何在地圖標注自己店鋪 地圖標注一個圓圈怎么用 廣州人工電銷機器人費用 怎樣把地圖標注導(dǎo)入公司地址 真人語音電銷機器人 寧波人工外呼系統(tǒng)有效果嗎 洛陽外呼系統(tǒng)平臺 電銷機器人被曝光 400外呼系統(tǒng)合法

SQL Server數(shù)據(jù)庫操作中,有時對于表中的結(jié)果集,滿足一定規(guī)則我們則認為是重復(fù)數(shù)據(jù),而這些重復(fù)數(shù)據(jù)需要刪除。如何刪除呢?本文我們通過一個例子來加以說明。

例子如下:

如下只要companyName,invoiceNumber,customerNumber三者都相同,我們則認為是重復(fù)數(shù)據(jù),下面的例子演示了如何刪除。

declare @InvoiceListMaster table ( ID int identity primary key ,  
 
companyName Nchar(20),  
 
invoiceNumber int,  
 
CustomerNumber int,  
 
rmaNumber int )  
 
insert  @InvoiceListMaster  
 
select N'華為', 1001,100,200  
 
union all  
 
select N'華為', 1001,100,300  
 
union all  
 
select N'華為', 1001,100,301  
 
union all  
 
select N'中興', 1002, 200,1     
 
union all  
 
select N'中興', 1002, 200,2  
 
select * from @InvoiceListMaster  
 
DELETE A  
 
from (  
 
select rown = ROW_NUMBER( )over( partition by companyname,  
 
invoicenumber,  
 
customerNumber   
 
order by companyname,  
 
invoicenumber,  
 
customerNumber ),  
 
companyname,  
 
invoicenumber,  
 
customerNumber  
 
from @InvoiceListMaster )a  
 
where exists ( select 1   
 
from ( select rown = ROW_NUMBER( )over( partition by companyname,  
 
invoicenumber,  
 
customerNumber   
 
order by companyname,  
 
invoicenumber,  
 
customerNumber ),  
 
companyname,  
 
invoicenumber,  
 
customerNumber  
 
from @InvoiceListMaster ) b  
 
where b.companyName = a.companyName  
 
and b.invoiceNumber = a.invoiceNumber  
 
and b.CustomerNumber = a.CustomerNumber  
 
and a.rown > b.rown  
 
)  
 
select * from @InvoiceListMaster 

以上的例子就演示了SQL Server數(shù)據(jù)庫刪除數(shù)據(jù)集中重復(fù)數(shù)據(jù)的過程,希望本次的介紹能夠?qū)δ兴斋@!

您可能感興趣的文章:
  • Sql Server使用cursor處理重復(fù)數(shù)據(jù)過程詳解
  • sqlserver清除完全重復(fù)的數(shù)據(jù)只保留重復(fù)數(shù)據(jù)中的第一條
  • SQL Server中刪除重復(fù)數(shù)據(jù)的幾個方法
  • sqlserver中重復(fù)數(shù)據(jù)值只取一條的sql語句
  • sqlserver合并DataTable并排除重復(fù)數(shù)據(jù)的通用方法分享
  • 教你幾種在SQLServer中刪除重復(fù)數(shù)據(jù)方法
  • MSSql簡單查詢出數(shù)據(jù)表中所有重復(fù)數(shù)據(jù)的方法

標簽:石家莊 煙臺 晉中 北海 珠海 咸寧 南昌 東營

巨人網(wǎng)絡(luò)通訊聲明:本文標題《SQL Server數(shù)據(jù)庫刪除數(shù)據(jù)集中重復(fù)數(shù)據(jù)實例講解》,本文關(guān)鍵詞  SQL,Server,數(shù)據(jù)庫,刪除,數(shù)據(jù),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《SQL Server數(shù)據(jù)庫刪除數(shù)據(jù)集中重復(fù)數(shù)據(jù)實例講解》相關(guān)的同類信息!
  • 本頁收集關(guān)于SQL Server數(shù)據(jù)庫刪除數(shù)據(jù)集中重復(fù)數(shù)據(jù)實例講解的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 镇沅| 绥滨县| 中阳县| 恩施市| 凉山| 祁阳县| 酉阳| 丰镇市| 陕西省| 个旧市| 五大连池市| 盈江县| 沙坪坝区| 邹平县| 桃园市| 民权县| 邵阳县| 定陶县| 青岛市| 承德市| 六盘水市| 揭阳市| 贡嘎县| 墨脱县| 阜宁县| 河东区| 随州市| 宿松县| 华亭县| 天祝| 黄梅县| 通山县| 积石山| 祥云县| 贡山| 吴堡县| 图片| 元阳县| 武宁县| 行唐县| 西藏|