dbTalk Databases Forums  

Last not null value from previous rows

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Last not null value from previous rows in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Shakespeare
 
Posts: n/a

Default Last not null value from previous rows - 01-26-2010 , 01:48 PM






I vaguely remember this has been asked and answered before, but can not
find the answer anymore:
Suppose I have a table in which a column has a value for some rows, and
none (null) for others. Is there a way to let a select statement (which
returns values from the current row) return the last non null value for
this column? So, in pseudo code:

select
col1,
col2,
"last-non-null value for col3"
from a_table
order by col1?


Thanks in advance,

Shakespeare

Reply With Quote
  #2  
Old   
Michel Cadot
 
Posts: n/a

Default Re: Last not null value from previous rows - 01-26-2010 , 01:56 PM






"Shakespeare" <whatsin (AT) xs4all (DOT) nl> a écrit dans le message de news: 4b5f4717$0$22934$e4fe514c (AT) news (DOT) xs4all.nl...
Quote:
I vaguely remember this has been asked and answered before, but can not
find the answer anymore:
Suppose I have a table in which a column has a value for some rows, and
none (null) for others. Is there a way to let a select statement (which
returns values from the current row) return the last non null value for
this column? So, in pseudo code:

select
col1,
col2,
"last-non-null value for col3"
from a_table
order by col1?


Thanks in advance,

Shakespeare
What about LAST_VALUE function?

Regards
Michel

Reply With Quote
  #3  
Old   
Shakespeare
 
Posts: n/a

Default Re: Last not null value from previous rows - 01-26-2010 , 03:32 PM



Op 26-1-2010 20:56, Michel Cadot schreef:
Quote:
"Shakespeare"<whatsin (AT) xs4all (DOT) nl> a écrit dans le message de news: 4b5f4717$0$22934$e4fe514c (AT) news (DOT) xs4all.nl...
|I vaguely remember this has been asked and answered before, but can not
| find the answer anymore:
| Suppose I have a table in which a column has a value for some rows, and
| none (null) for others. Is there a way to let a select statement (which
| returns values from the current row) return the last non null value for
| this column? So, in pseudo code:
|
| select
| col1,
| col2,
| "last-non-null value for col3"
| from a_table
| order by col1?
|
|
| Thanks in advance,
|
| Shakespeare

What about LAST_VALUE function?

Regards
Michel


Thanks Michel,

that was the one I was looking for!

Shakespeare

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.