Skip to content
Advertisement

Populating rows in table with previous row value oracle sql

Here above the data is grouped by person then their duties are listed :

I need a way to get the data to look like this using oracle sql :

having a bit of trouble iterating over every row… dont mind if its plsql – sql prefered tho

Tried a few things… but it goes back to null after the 2nd row for each person

Advertisement

Answer

One method is lag(ignore nulls):

This is fetching the previous non-NULL value from the name columns, where “previous” is based on the ordering of the id column.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement