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;