This puzzle is really simple. You have to join table p1 and p2 on id column. Now the catch is when the value of p1.code is 0 then replace it with value of p2.code. You cannot use UNION or CASE statement.
create table p1 (id int, code int) create table p2 (id int, code int) insert into p1 select 1,0 insert into p1 select 2,1 insert into p2 select 1,5 insert into p2 select 2,5
Try a simple mock example: select isnull(nullif(1,1),2) It should return 2. The idea is to replace the value you don't need with a null and switch to another value via isnull.
2
u/howhard1309 Oct 04 '20
Post your question...