1.select * from JT_WEBK_NEWS as a
where (
select count(*) from JT_WEBK_NEWS
where subclassid=a.subclassid and NEWSID > a.NEWSID
) < 5
order by NEWSID desc
2. SELECT 字段1, 字段2, 字段3
FROM (SELECT 字段1, 字段2, 字段3,
ROW_NUMBER() OVER(PARTITION BY 字段3 ORDER BY 字段1) rk
FROM tab) t
WHERE rk <= 2