SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 NULL Values
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

daidaluus
Yak Posting Veteran

73 Posts

Posted - 04/20/2010 :  07:42:25  Show Profile  Reply with Quote
I have the following data

id value
-- -----
1 10
2 NULL
3 NULL
4 8
5 NULL
6 12
7 NULL
8 NULL
9 NULL

How can i get the following result?

id value
-- -----
1 10
2 10
3 10
4 8
5 8
6 12
7 12
8 12
9 12

or how can I update the table to have these values?

khtan
In (Som, Ni, Yak)

Singapore
17642 Posts

Posted - 04/20/2010 :  08:57:28  Show Profile  Reply with Quote

select	d.id, 
	isnull(	d.value,
		(select top 1 value from data x where x.id < d.id and x.value is not null order by id desc)
		)
from	data d



KH
Time is always against us

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000