>SELECT ; > pitype_id,; > MAX(expdate); > FROM PI ; > WHERE eqtype_id=2 AND equip_id=2246 ; > GROUP BY 1; > INTO CURSOR Result > >SELECT ; > a.pi_id,; > a.pitype_id,; > a.expdate ; > FROM Result b JOIN PI a ON a.pitype_id = b.pitype_id ; > and a.expdate = b.expdate ; > INTO CURSOR Result >>