Find and remove duplicate rows by two columns

前端 未结 7 603
鱼传尺愫
鱼传尺愫 2021-02-01 08:52

I read all the relevant duplicated questions/answers and I found this to be the most relevant answer:

INSERT IGNORE INTO temp(MAILING_ID,REPORT_ID) 
SELECT DISTI         


        
7条回答
  •  离开以前
    2021-02-01 09:33

    In a large data set if you are selecting the multiple columns in the select clause ex: select x,y,z from table1. And the requirement is to remove duplicate based on two columns:from above example let y,z then you may use below instead of using combo of "group by" and "sub query", which is bad in performance:

    select x,y,z 
    from (
    select x,y,z , row_number() over (partition by y,z) as index_num
    from table1) main
    where main.index_num=1
    

提交回复
热议问题