1.查询最新的分组倒序,最前几个
SELECT
*
FROM
(
SELECT
max.*
FROM
( SELECT DISTINCT a.* FROM t_journal_issue a WHERE a.if_delete = 1 ORDER BY a.release_time DESC ) max
GROUP BY
max.journal_id
) x
ORDER BY
x.release_time DESC
2.按组统计
SELECT
publish_field_id AS id,
count(*) AS count
FROM
t_article
WHERE
publish_field_id IS NOT NULL
AND LENGTH(trim(publish_field_id)) > 1
GROUP BY
publish_field_id
网友评论