Home > database >  Database query problem, could you tell me how to query data top ten every day
Database query problem, could you tell me how to query data top ten every day

Time:04-13

The structure of the table is id, country name, date, quantity
Do the top ten want to query the number every day data should be how to write SQL statements

CodePudding user response:

Select * from table where create_time number='the date today' order by desc limit 10

CodePudding user response:

Is not as long as a day to day before ten

CodePudding user response:

This code level solve ah

CodePudding user response:

Or on a stored procedure

CodePudding user response:

Select *
The from (
Select the if (@ date=a.c reate_time, @ rownum:=@ rownum + 1, @ rownum:=1) as rownum,
@ date:=a.c reate_time, a.c olumn1, biggest olumn2...
The from (
Select *
From the table
The order by create_time, quantity desc). A,
: (select @ rownum=0, @ date:=' ')
b) a
Where a.r ownum & lt;=10;

  • Related