I am trying get the first non-null value from some rows that belong to a group. How can I achieve it?
with t (id, grp, lbl) as
(
select 1, 9, null from dual union all
select 2, 9, null from dual union all
select 3, 9, 'p' from dual union all
select 4, 9, null from dual union all
select 5, 9, 'a' from dual union all
select 6, 9, 'd' from dual
)
select min(id) id, min(lbl /* ignore nulls */) keep (dense_rank first order by id) minlbl from t
group by grp
;
obviously, I cannot get the expected result from the above first aggregation query.
Expected result:
ID MINLBL
---------- ------
1 p
version: 12.2.0.1.0
Message was edited by: mNem
Modified the grp value to avoid the confusion after the post from @Ranagal.