I have 2 tables
aaa
on_date datetime null,
channel_id numeric(10,0) null,
type_id numeric(10,0) null,
amount numeric(10,0) null
bbb
channel_id numeric(10,0) null
type_id numeric(10,0) null
I want to do an update to aaa.amount to 0 of
- only the common channel_ids and type_ids when bbb.type_id is not null
or
of only the common channel_ids and ALL the type_ids when the bbb.type_id is null
aaa
2014-09-13 1 3 12
2014-09-13 1 4 16
2014-09-13 2 1 11
bbb (case 1. )
1 3
bbb (case 2. )
1 null
In first case only the first aaa record should have amount = 0 In the second case the first 2 records of aaa should have amount = 0 Thank you