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 rows based on certain conditions in Oracle.

3199866Mar 16 2016 — edited Mar 17 2016

I am trying to insert rows in a table with certain conditions -

There is a table with fields  - ID, month, year, and value. The logic that I need to implement is if for an ID there is no row for a specific month and year then I want to insert that row into this table.

ID   Month  Year  Value

1     01        2016     2

1     02        2016    10

2     11        2015   15

2     12        2015    5

2     09        2015    8

Now, in this example, since for ID=1 Month/ Year 03/2016 is missing so in this case I would like to insert

1      03      2016     0

Similarly, Oct 2015 is missing so it wil be like

2     10     2015       0

I am not able to figure it out myself, can someone help me with this! Any help will be really appreciated!

Thanks,

Priyanka

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 14 2016
Added on Mar 16 2016
13 comments
2,734 views