博客文章归档SQL语句

2024-11-04 17:47:25 总阅读量:222,本日阅读:5,本周阅读:25,本月阅读:222 0条
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
标签 SQL 博客

非特殊说明,本博所有文章均为博主原创。

-----