Lets go to the basics, is this what you are looking for?
Code:SQL> SQL> create table PATIENT( 2 patient_nbr number(10)); Table created. SQL> insert into PATIENT select 1 from dual; 1 row created. SQL> insert into PATIENT select 2 from dual; 1 row created. SQL> insert into PATIENT select 3 from dual; 1 row created. SQL> insert into PATIENT select 4 from dual; 1 row created. SQL> insert into PATIENT select 5 from dual; 1 row created. SQL> commit; Commit complete. SQL> SQL> create table FORM( 2 patient_nbr number(10), 3 some_date date); Table created. SQL> insert into FORM select 2,NULL from dual; 1 row created. SQL> commit; Commit complete. SQL> SQL> select * from PATIENT; PATIENT_NBR ----------- 1 2 3 4 5 SQL> SQL> select * from FORM; PATIENT_NBR SOME_DATE ----------- --------- 2 SQL> SQL> insert 2 into FORM 3 select a.patient_nbr, sysdate 4 from PATIENT a 5 where (a.patient_nbr not in (select b.patient_nbr 6 from FORM b)) 7 ; 4 rows created. SQL> commit; Commit complete. SQL> SQL> select * from FORM; PATIENT_NBR SOME_DATE ----------- --------- 2 1 15-SEP-10 3 15-SEP-10 4 15-SEP-10 5 15-SEP-10 SQL>




Reply With Quote