SELECT m.y,t.m,t.num,t.text
FROM
(
SELECT FROM_UNIXTIME(`tour_addtime`, '%Y') AS y,
FROM_UNIXTIME(`tour_addtime`, '%m') AS m,
count(`tour_id`) AS num,
FROM_UNIXTIME(`tour_addtime`, '%Y年%m月') AS text
FROM `hl_tour`
GROUP BY y,m
ORDER BY y desc,m DESC
) t
LEFT JOIN
(SELECT FROM_UNIXTIME(`tour_addtime`, '%Y') AS y, MAX(FROM_UNIXTIME(`tour_addtime`, '%m')) AS m
FROM `hl_tour`
GROUP BY y ) m
ON t.y=m.y
AND t.m=m.m
非特殊说明,本博所有文章均为博主原创。
如若转载,请注明出处:https://www.ihulang.com/index/info/23.html