Oracle 'Partition By' and 'Row_Number' keyword

后端 未结 4 1190
南方客
南方客 2020-11-30 20:25

I have a SQL query written by someone else and I\'m trying to figure out what it does. Can someone please explain what the Partition By and Row_Number

4条回答
  •  悲哀的现实
    2020-11-30 21:12

    I often use row_number() as a quick way to discard duplicate records from my select statements. Just add a where clause. Something like...

    select a,b,rn 
      from (select a, b, row_number() over (partition by a,b order by a,b) as rn           
              from table) 
     where rn=1;
    

提交回复
热议问题