Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> how to do this with sql?
Hi ,
I have to do the following :
table_a has set of records based on the entry date:
(entry_date,name,surname,customer_id) :
20060510,null,yy,1
20060509,xx,null,1
What i need is to combine these two rows into 1 , the final record will be:
xx,yy,1 ( entry_date is not needed in final record) .
The rule for each column is : get the first non-null value which is entered last.
How can i do this? I tried some analytic functions but could not succeed.
By using seperate sql statements i can do the following:
SELECT name
FROM table_a where name is not null and entry_date =
(select max(entry_date)
from table_a where name is not null) SELECT surname FROM table_a where surname is not null and entry_date =
(select max(entry_date)
from table_a where surname is not null) Is it possible to do this in a single sql statement?
Kind Regards,
tolga
Received on Wed May 10 2006 - 09:40:51 CDT