Skip to Main Content

analytical function help

OU_230Sep 18 2017 — edited Sep 19 2017

I have following table:

with  tbl as (select 1 col1, 'a'  col2 from dual

            union select 2 , 'a' from dual

            union  select 3 , 'b' from dual

            union  select 4 , 'a' from dual

            union  select 5 , 'a' from dual

            union  select 6 , 'b' from dual

            union  select 7 , 'b' from dual

) select   * from tbl order by col1;

I want following result  i.e first value from  col2   whenever col2 value changes.

1 ,a

3 ,b

4 ,a

6 ,b

How can I do this in SQL  using analytical function

Comments
Post Details
Added on Sep 18 2017
5 comments
381 views