Home » SQL & PL/SQL » SQL & PL/SQL » SQL Query Help (SQL Developer)
SQL Query Help [message #666018] Sun, 08 October 2017 08:31 Go to next message
reddy0422
Messages: 9
Registered: June 2014
Junior Member
Hello Gurus- Please help me on the below scenario, based on the contract_no, the data should be inserted into 2 different tables.

create table xx
(id number,
c_num varchar2(100),
validity_date date,
contract_no varchar2(30),
name1 varchar2(30),
name2 varchar2(50));


insert into xx values(100,6789,sysdate,'C100','xyz','abc');
insert into xx values(101,6789,sysdate,'C100','xyz','abc');
insert into xx values(102,6789,sysdate,'C100','xyz','abc');
insert into xx values(103,6789,sysdate,'C100','xyz','abc');
insert into xx values(104,6789,sysdate+1,'C101','kljio','lkjllk');
insert into xx values(105,6789,sysdate+2,'C101','kljio','lkjllk');
insert into xx values(106,6789,sysdate+3,'C101','uijhu','ljopj');
insert into xx values(107,6789,sysdate,'C102','khouh','uoikj');


--Table-1 (If all columns has same data for same CONTRACT_NO- It should insert only one row into Table1 with ID's separted with delimiter Smile
ID,c_num,Validity_date,contract_id,name1,name2
100:101:102:103,6789,07-OCT-17,C100,xyz,abc
107,6789,07-OCT-17,C102,khouh,uoikj

create table Table1 (id varchar2(100), c_num varchar2(100), validity_date date, contract_no varchar2(30), name1 varchar2(30), name2 varchar2(50));
create table Table2 (id number, c_num varchar2(100), validity_date date, contract_no varchar2(30), name1 varchar2(30), name2 varchar2(50));

--Table-2 (If the data in any of the columns is different for the same CONTRACT_NO- It should insert into Table2)
104,6789,08-OCT-17,C101,kljio,lkjllk
105,6789,09-OCT-17,C101,kljio,lkjllk
106,6789,10-OCT-17,C101,uijhu,ljopj
Re: SQL Query Help [message #666020 is a reply to message #666018] Sun, 08 October 2017 08:41 Go to previous message
BlackSwan
Messages: 25721
Registered: January 2009
Location: SoCal
Senior Member
https://community.oracle.com/thread/4087442
Previous Topic: returning collection from a loop and bulk collect
Next Topic: Heterogeneous DB error propagating past WHEN OTHERS
Goto Forum:
  


Current Time: Fri Nov 24 12:44:14 CST 2017

Total time taken to generate the page: 0.02401 seconds