with t (A,B,C,D) as (
select 1, 1, 1, 'Q' from dual union all
select 1, 2, 1, 'Q' from dual union all
select 1, 1, 2, 'Q' from dual union all
select 1, 1, 3, 'Q' from dual)
select *
from (select A,B,C,D
, row_number() over(partition by C order by B,A asc) rn
from t
where D= 'Q')
where rn = 1;