Home » SQL & PL/SQL » SQL & PL/SQL » Pls help me out, its very urgent
Pls help me out, its very urgent [message #41232] Wed, 11 December 2002 14:56 Go to next message
Vinod
Messages: 76
Registered: April 1999
Member
I have a newly created table A as follows

SECTOR_CODE
SECTOR_DESCRIPTION
SECTOR_UPDATED_ID
SECTOR_UPDATED_DATE

SECTOR_CODE and SECTOR_DESCRIPTION are NOT NULL columns

I have another table B with same sector_description column.

The problem is that i have to insert sector_description column in table A by taking the distinct sector_description values from table B, how do i do this so that it takes the latest distinct values from table B.

values for the other 3 columns should be as follows

SECTOR_CODE is from a SEQUENCE
SECTOR_UPDATED_ID is USER
SECTOR_UPDATED_DATE is SYSDATE

pls help me out with this, its very urgent

Thanks

Vinod
Re: Pls help me out, its very urgent [message #41237 is a reply to message #41232] Wed, 11 December 2002 15:43 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
If you are populating the date column in table_a with sysdate and not the corresponding date for the description from table_b, there is no concept of the "latest" entry from table_b.

The insert would just be the distinct descriptions from table_b.

insert into a
  select seq.nextval, sector_description, user, sysdate
    from (select distinct sector_description
            from b);
Re: Pls help me out, its very urgent [message #41241 is a reply to message #41237] Wed, 11 December 2002 16:25 Go to previous message
Vinod
Messages: 76
Registered: April 1999
Member
Thanks a lot
Previous Topic: "Captured" SQL Query
Next Topic: SQL LOADER PROBLEM
Goto Forum:
  


Current Time: Tue May 14 20:15:29 CDT 2024