oracle - How to Formulate IF THEN Rule as a Predicate -
i have table codes , processing dates. there business rule saying if code = 3 occures on day codes = 1 on day should supressed.
create table test (code number , processing_date date); insert test values (1,trunc(sysdate)); insert test values (2,trunc(sysdate)); insert test values (3,trunc(sysdate)); insert test values (1,trunc(sysdate)-1); insert test values (2,trunc(sysdate)-1); commit;
i figured solution. works fine, i'm extremly unhappy predicate, without comment not realy intuitive me. i'm sure i'll question meaning of predicate!
with codes ( select processing_date, code, max(case when code = 3 'y' else 'n' end) on (partition processing_date) day_with_c3 test) select * codes -- if there day code = 3 ignore code = 1 (day_with_c3 != 'y' or code != 1) order processing_date, code;
is there other formulation horrible !a or b, describing better meaning of business rule if b?
try:
select * test t code <> 1 or not exists ( select null test t1 t1.processing_date = t.processing_date , code = 3 ) order 2,1
Comments
Post a Comment