select * from t_edm_maer139 WHERE (mani,manr,usgr) in (select distinct on (manr)mani,manr,usgr from t_edm_maer139 WHERE usgr LIKE 'PT%' order by manr,mani DESC ) AND stat NOT LIKE 'FR' ORDER BY manr