Home » SQL & PL/SQL » SQL & PL/SQL » fill missing values (Oracle 10.2.0.3 / Windows Server)
fill missing values [message #354255] Fri, 17 October 2008 03:50 Go to next message
buck444
Messages: 80
Registered: January 2006
Location: Luxembourg
Member
Hi,

I have a table like below

ID  Number
A   1
A   
A   
A   2


How can I fill the NULL values between 1 and 2 with 1, until the value changes to 2?

In general: Is it possible to fill NULL values with the last known value, until the value is not equal to NULL?
Re: fill missing values [message #354258 is a reply to message #354255] Fri, 17 October 2008 04:11 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
You have no ordering in your table, so it might as well be
ID   Number
A    1
A    2
A
A

First define a way to order your rows.

The solution you are after can be found using analytical functions
Re: fill missing values [message #354281 is a reply to message #354255] Fri, 17 October 2008 06:01 Go to previous messageGo to next message
Serious Sam
Messages: 21
Registered: September 2007
Junior Member
Look at the link below,

http://asktom.oracle.com/pls/asktom/f?p=100:11:1521941833324520::::P11_QUESTION_ID:10286792840956

Thanks,
Sam
Re: fill missing values [message #354317 is a reply to message #354255] Fri, 17 October 2008 12:05 Go to previous message
buck444
Messages: 80
Registered: January 2006
Location: Luxembourg
Member
thanks both for suggestions. helped a lot!
Previous Topic: ora-01720
Next Topic: Using a keyword in a query?
Goto Forum:
  


Current Time: Wed Dec 07 22:14:34 CST 2016

Total time taken to generate the page: 0.05575 seconds