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!

repeat Column value in Oracle

user12190125Mar 22 2012 — edited Mar 22 2012
I have the following table:

SNO DEPT Name
1 17 RAHUL
2 0 SACHIN
3 0 SAMEER
4 21 GUHAN
5 0 MADAN
6 0 MAHESH
7 19 NISHA
8 0 PREETI
9 0 MUHAMMAD
10 25 SANJAY
11 0 RAKESH
12 0 ANIR
13 0 VIVEK
14 0 AVNEESH
15 28 SOURABH
16 0 SAMEER

I want to update Dept column in a manner so that the first value should be repeated until it encounters the second value,then the second value should be repeated until it encounters third value and so on.

For example I want the output as shown below:

SNO DEPT NAME
1 17 RAHUL
2 17 SACHIN
3 17 SAMEER
4 21 GUHAN
5 21 MADAN
6 21 MAHESH
7 19 NISHA
8 19 PREETI
9 19 MUHAMMAD
10 25 SANJAY
11 25 RAKESH
12 25 ANIR
13 25 VIVEK
14 25 AVNEESH
15 28 SOURABH
16 28 SAMEER

Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 19 2012
Added on Mar 22 2012
9 comments
1,186 views