SELECT a.* FROM ( SELECT t1.*,(SELECT count(*)+1 FROM qps_hour WHERE hour=t1.hour AND id<t1.id AND time="2020-03-15") AS g_id FROM qps_hour t1 WHERE t1.time="2020-03-15" ) AS a WHERE a.g_id<=3
image.png
SELECT a.* FROM ( SELECT t1.*,(SELECT count(*)+1 FROM qps_hour WHERE hour=t1.hour AND id<t1.id AND time="2020-03-15") AS g_id FROM qps_hour t1 WHERE t1.time="2020-03-15" ) AS a WHERE a.g_id<=3
image.png
本文标题:mysql 先分组然后组内排序,之后取出前三个值
本文链接:https://www.haomeiwen.com/subject/uzzoehtx.html
网友评论