Solved

oracle 11g

Posted on 2015-02-02
2
134 Views
Last Modified: 2015-02-02
Hi,

I have a table as below

create table t_temp_tb(a number,b number);

and data  like  column a is sequence number and column b contains values for some  rows only like below.
1      400      
2            
3            
4      500      
5            
6            

Now I would like to update the table as below
ie after selecting from the table

(select a,b from t_temp_tb order by a;)

1      400      
2      400      
3      400      
4      500      
5      500      
6      500

We do not know how many records exists in the table in advance.
Can you please let me know how can I update?
Because this update needs to be run daily on a table automatically in a job.

thanks.
0
Comment
Question by:GouthamAnand
2 Comments
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 total points
Comment Utility
UPDATE t_temp_tb t1
   SET b =
           (SELECT b
              FROM (SELECT a, LAST_VALUE(b IGNORE NULLS) OVER (ORDER BY a) b FROM t_temp_tb) t2
             WHERE t1.a = t2.a);
0
 

Author Closing Comment

by:GouthamAnand
Comment Utility
Thank you very much.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
oracle query help 18 75
SQL query of Oracle 10g database. 8 56
dates - loop 12 40
SQL Retrieve Values 4 40
Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now