Using the oracle, left table contains a accounting subject acct_cd, if a accounting subject is' 1001 ', then the connection b table for balance amt, namely
Select * from a
Left the join b
Using (cust_no)
When a accounts for '1002', the connection table c get balance, namely
Select * from a
Left the join c
Using (cust_no)
Now have a solution:
A select few fields, case acct_cd when '1001' then b.a mt, when '1002' then c.a. mt
From a
Left the join b
Using (cust_no)
Left the join c
Using (cust_no)
Scheme 2:
A select few fields, amt
From a
Left the join b
Using (cust_no)
Where a.a cct_cd='1001'
Union all
A select few fields, amt
From a
Left the join c
Using (cust_no)
Where a.a cct_cd='1002'
Excuse me which solution is better, in the actual cases, the subject is more, if use 2 code would seem to be very long, but plan a is likely to lower efficiency? There is no better solution? Thank you for your bosses