Time:09-23
CodePudding user response:
can check out the
Quote: refer to the second floor qq_29098449 response: can check out the you will be familiar with mySQL,
Example - are as follows: - see table The create table t (date varchar (10), id varchar (10), high int, weight int) - insert the data Insert into t Select '2019-03-11', 'wang, 170, 62 Union select '2019-03-11', 'zhang, 171, 63 Union select '2019-03-11', 'xiao li, 172, 64 Union select '2019-02-15', 'wang, 170, 63 Union select '2019-02-15', 'zhang, 171, 63 Union select '2019-02-15', 'xiao li, 172, 64 Union select '2019-01-21', 'wang, 170, 64 Union select '2019-01-21', 'zhang, 171, 62 Union select '2019-01-21', 'xiao li, 172, 64 Union select '2019-01-01', 'wang, 170, 62 Union select '2019-01-01', 'zhang, 171, 67 Union select '2019-01-01', 'xiao li, 172, 64 Query - Select * from (Select @ the rowid:=the if (@ rank=id, @ the rowid + 1, 1) newid, date, id, high, weight, @ rank: id=flag The from t, (select @ the rowid:=0, @ rank:=' ') a The order by the id, the date desc) t Where newid=1
Page link:https//www.codepudding.com/database/24937.html