在一个数据表里,如果statistic_date为主键,其他数据非主键,则找最大日期的数据为: select * from table_1 where statistic_date
在一个数据表里,如果statistic_date为主键,其他数据非主键,则找最大日期的数据为:
select * from table_1 where statistic_date=(SELECT max(statistic_date) from table_1)
在一个数据表里,如果fund_id、statistic_date为主键,其他数据非主键,则分别找每条fund_id最大日期的数据为:
SELECT fdre.* FROM(SELECT fund_id,MAX(statistic_date) msd FROM `table_2`GROUP BY fund_id) TINNER JOIN table_2 fdreON fdre.fund_id = T.fund_idAND fdre.statistic_date = T.msd
在一个数据表里,如果fund_id、year、statistic_date为主键,其他数据非主键,则分别找每条fund_id,每个年最大日期的数据为:
SELECT fdre.* FROM(SELECT fund_id,`year`,MAX(statistic_date) msd FROM `table_2`GROUP BY fund_id,year) TINNER JOIN table_2 fdreON fdre.fund_id = T.fund_idAND fdre.statistic_date = T.msdAND fdre.year= T.year
来源地址:https://blog.csdn.net/qq_44821149/article/details/130934259
--结束END--
本文标题: mysql找最大日期的数据
本文链接: https://www.lsjlt.com/news/401518.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-16
2024-05-16
2024-05-16
2024-05-15
2024-05-15
2024-05-15
2024-05-15
2024-05-15
2024-05-15
2024-05-15
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0