Home > database >  Rookie on sorting delete oracle weight problems
Rookie on sorting delete oracle weight problems

Time:09-26

I have a table, there is a number, time, and other fields, I want to delete, according to the number take number in time the largest whole records, a combination of distinct and Max as if can only take two fields, other fields take not to come out, want to ask next great god the SQL statement to how to write,

CodePudding user response:

Row_number () over (partition by number order by desc) rn
Query using an rn=1, problem solved,

CodePudding user response:

The delete from the table where the rowid not in (select Max (rowid) from table group by mobile phone)

CodePudding user response:

 select * 
The from tab_phone_test t
Where t.p hone_time in (select Max (t1) phone_time)
The from tab_phone_test t1
Group by t1. Phone_num)
  • Related