select aa.* from (select row_number() over(partition by prj_id order by fnmac_id desc) as rn,
prj_id,fnmac_id,... from tab where ....) aa
where rn <= 2;
prj_id,fnmac_id,... from tab where ....) aa
where rn <= 2;
from tab a where (a.fnmac_id) in (select b.fnmac_id from tab b where b.prj_id = a.prj_id and rownum <=2 order by b.fnmac_id desc)
select max(fnmc_id),prjid from tab group by prjid
请大家指教,谢谢楼上两位,大家参与都会有回报的