Mysql 如何查找最近20个星期二的数据
我想找到最近20个星期二的数据Mysql 如何查找最近20个星期二的数据,mysql,sql,sql-date-functions,Mysql,Sql,Sql Date Functions,我想找到最近20个星期二的数据 Date value 2020-03-03 01:12:15 5 2020-02-25 07:12:15 13 2020-02-24 08:12:15 1 2020-02-23 09:12:15 32 2020-02-22 10:12:15 7 2020-02-21 11:
Date value
2020-03-03 01:12:15 5
2020-02-25 07:12:15 13
2020-02-24 08:12:15 1
2020-02-23 09:12:15 32
2020-02-22 10:12:15 7
2020-02-21 11:12:15 43
2020-02-20 12:12:15 7
2020-02-19 13:12:15 1
2020-02-18 14:12:15 31
2020-02-17 15:12:15 14
还有一个
我期望的输出是
Date value
2020-03-03 01:12:15 5
2020-02-25 07:12:15 13
2020-02-18 14:12:15 31
等等这就是你想要的吗
select t.*
from t
where weekday(date) = 2
order by date desc
limit 3 -- or 20
您可以使用year和dayofweek
select * from myTable
where year(date) = 2020
and dayofweek(date) = 5
您可以使用下面的查询
select t.*
from t
where weekday(date) = 2
order by date desc
limit 20
请看:最后20个星期二?有没有价值观?(即最近20*7+6个日期后的任何星期二?)