Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

sql query for this???

433185Nov 1 2005 — edited Nov 3 2010

Hi

I have a table with data in the following format

Col1   COL2
A       2001
B
C
D
E
F       2002
G
H
I        2003

I want a query that would fill the gaps with the last non-null value in col2

desired output

Col1   COL2       output_col
A       2001        2001
B                      2001
C                      2001
D                      2001
E                      2001
F       2002        2002
G                      2002
H                      2002
I        2003        2003

as you can see the output_column shows the last non-null value of the col2 for each row..if for any row it finds a new col2 value then it shows that value for that row and for next rows until it finds another new one and so on

how to achive that from sql query...??

regards,

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 6 2006
Added on Nov 1 2005
8 comments
2,145 views