WITH t AS
(select 1 ID ,0 step from dual UNION
select 1 ID ,1 step from dual UNION
select 1 ID ,2 step from dual UNION
select 2 ID ,0 step from dual UNION
select 2 ID ,1 step from dual )
/*SELECT ID FROM t GROUP BY ID HAVING MAX(STEP)=2*/
/*SELECT a.* FROM t a where step=2;*/
SELECT a.* FROM t a,
(SELECT ID FROM t GROUP BY ID HAVING MAX(STEP)=2) b
WHERE a.ID=b.id;