SELECT * FROM PITEMREVISION 
where puid in (
SELECT irpuid from (

SELECT 
  MAX(PITEMREVISION.PSEQUENCE_ID),
  MAX(PITEMREVISION.PUID) as irpuid
FROM PITEMREVISION
WHERE PITEMREVISION.PITEM_REVISION_ID LIKE 'Rev%'
GROUP BY PITEMREVISION.RSEQUENCE_ANCHORU )
)