SQL command 如何列出重複的值 - S7an Insights

Breaking

S7an Insights

生活 × 技術 × 分享 讓複雜的問題,有條理地解決。

2017年8月31日 星期四

SQL command 如何列出重複的值

以下case以SQL server為例:
--SQL server的目的端table1,其index會限制資料primary key,須檢查來源端table1_temp內是否有重複的資料;select欄位是primary key清單;P_NO是唯一值
select CUST, PRODUCT, P_NORE_DATEITEM_ID
from table1 where 1=1
group by CUST, PRODUCT, P_NORE_DATEITEM_ID
having count(P_NO) > 1
透過上述SQL command,就能判斷哪些P_NO有重複出現。



Ref:
http://www.neo.com.tw/archives/454

http://www.programmer-club.com.tw/ShowSameTitleN/sqllanguage/2559.html

沒有留言:

張貼留言

問題沒有大小或好壞