Home > database >  Handsome little brothers, encounter a problem of data query, consult everybody brethren
Handsome little brothers, encounter a problem of data query, consult everybody brethren

Time:09-29


Dear little brother,
How to implement the data search:
Different Object query the last N days data,
Data structure of the diagram below, keep yellow data


Thank you for

CodePudding user response:

Seems to not have this kind of method, try the PL

CodePudding user response:

MSSQL? If the MSSQL, direct row_number () over (partition by object the order by the date desc) as NNNN, then select NNNN range and will NNNN reverse order

CodePudding user response:

refer to the second floor illiterate old gu response:
MSSQL? If the MSSQL, direct row_number () over (partition by object the order by the date desc) as NNNN, then select NNNN range and will NNNN reverse can

If it is MySQL. What should I do? Didn't find this function

CodePudding user response:

MySQL 8.0 have a ranking function row_number,

As for the low version, there is no special off, you can have a look at:
https://blog.csdn.net/xiaoping_1988/article/details/83309199
  • Related