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
CodePudding user response:
Solution in the presence of a pair of long may the bug, who quickly slow depends, if you want to clear logic, not directly make the pretreatment on the balance sheetCodePudding user response: