SELECT DISTINCT MAX(ir2.psequence_id)
  FROM infodba.PITEMREVISION ir
       INNER JOIN infodba.PITEMREVISION ir2 On ir.rsequence_anchoru = ir2.rsequence_anchoru or (ir2.puid = 'wlLJ65NcAjJ1aC' and ir2.rsequence_anchoru is null)
   Where ir.puid = 'wlLJ65NcAjJ1aC' 
   
   