You may use one of the following :
with t(colA,ColB) as
(
select 1,'XX' from dual union all
select 2,'XX' from dual union all
select 3,'XX' from dual union all
select 4,'XX' from dual
)
select ColB
from t
where ColumnB = 'XX' and rownum = 1;
or
select ColB from
(
with t(colA,ColB) as
(
select 1,'XX' from dual union all
select 2,'XX' from dual union all
select 3,'XX' from dual union all
select 4,'XX' from dual
)
select ColB,
row_number() over (order by ColB) as rn
from t
)
where ColumnB = 'XX' and rn=1;
or if your DB version is 12c, this one works also :
with t(colA,ColB) as
(
select 1,'XX' from dual union all
select 2,'XX' from dual union all
select 3,'XX' from dual union all
select 4,'XX' from dual
)
select ColB
from t
where ColumnB ='XX'
fetch {first|next} 1 {row|rows} only;
one of the keywords first or next and row or rows should be preferred.