Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Insert non duplicate values

SainaaJun 16 2020 — edited Jun 17 2020

Hello I want to insert non duplicate values into table.

with sample_data (id, a_cnt, b_cnt, c_cnt, a_amt, b_amt, c_amt) as (

  select 1, 1, 1, 1, 3, 2, 1 from dual union all

  select 2, 1, null, 2, 3, null, 3 from dual union all

  select 3, 1, 1, null, 2, 2, null from dual union all

  select 4, null, null, null, null, null, null from dual

)

SELECT * FROM sample_data

Imagine this is the result from my today's query. Tomorrow when I run the same query some data added some data stays and some data gone.

What I want to is insert non duplicate query result into my table.

day 1 id amt name

          1  200  a

          2 300 b

          3  400 c

day 2 id amt name

          1  200  a

          3  300  b

          4 400  d

          5 500   e

after insert day 2 data my table should become like this.

id amt name

1  200 a

2 300 b

3 400 c

4 400 d

5 500 e

This post has been answered by mathguy on Jun 17 2020
Jump to Answer
Comments
Post Details
Added on Jun 16 2020
1 comment
833 views