SQL How to remove duplicates within select query?

前端 未结 7 889
甜味超标
甜味超标 2021-01-04 07:05

I have a table which looks like that:

\"alt

As You see, there are some date duplicates, so how t

7条回答
  •  感情败类
    2021-01-04 07:09

    here is the solution for your query returning only one row for each date in that table here in the solution 'tony' will occur twice as two different start dates are there for it

    SELECT * FROM 
    (
        SELECT T1.*, ROW_NUMBER() OVER(PARTITION BY TRUNC(START_DATE),OWNER_NAME ORDER BY 1,2 DESC )  RNM
        FROM TABLE T1
    )
    WHERE RNM=1
    

提交回复
热议问题