Home > database >  Mysql for grouping sorted values
Mysql for grouping sorted values

Time:09-30

Such as type, there are three types, and then the query results according to the type group, ordered by date (the date may be the same for each of the types of data, and then how to find out, before each type of 10 data (each type data according to time descending order)

CodePudding user response:

E.g.
 select * from (select *, row_number () over (partition by type, the order by the date) as an RN from tabName) as T where RN<=10; 
  • Related