MySQL sql中使用 in()查询时,集合范围内每个id都显示最新的几条

 在这里显示最新的3条

select a.* from pds_daily_production_report a where 3>(select count(*) from pds_daily_production_report where id=a.id and date > a.date)
and company_id="1"
and 
id in ("42497359170000","42367337080000") 
order by a.uwi desc, a.date desc

效果如下图:

发布了46 篇原创文章 · 获赞 4 · 访问量 5029

猜你喜欢

转载自blog.csdn.net/qq_35862393/article/details/102983573