I have 3 tables:
table1:
id
111
222
333
444
table2:
id ---- flag
111 ---- yes
222 ---- yes
444 ---- yes
table3:
id ---- flag
111 ---- no
222 ---- yes
333 ---- yes
I want to create a new table that populates with 'yes' to '1' and 'no' or non-existent to '0', but only those records which have at least one 'no' or non-existent as such:
new table:
id ------- table2flag ----------- table3flag
111 ------- 1 ------------------- 0
333 -------- 0 ------------------- 1
444 -------- 1 ------------------- 0
Notice how there is no entry for 222 since they are both yes in both tables. How can I achieve this with Oracle sql?