-- ALTER SESSION SET NLS_COMP=LINGUISTIC 
-- ALTER SESSION SET NLS_SORT=BINARY_CI 

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
)
)