我正在尝试使用两个表来获取结果集
- 追踪平衡
- 老化
表的结构是
老化
loc | glAcct | Amount
-----------------------------------
1013 | 1101 | 200
-----------------------------------
1211 | 1102 | 300
-----------------------------------
试算表
loc | g1101 | g1102
------------------------------
1013 | 20 | 30
------------------------------
1211 | 10 | 40
-----------------------------
现在我要做的是将行与我现在想要的列匹配
loc | glAcct | agigingAmount | Trialbalance Amount
--------------------------------------------------------------
1013 | 1101 | 200 | 20
--------------------------------------------------------------
1211 | 1102 | 300 | 40
-------------------------------------------------------------
我尝试过类似的案例陈述
select ag.loc,ag.glAcct,
case
when ag.glAcct = '1101' then select g1101 from trialbalance
when ag.glAcct = '1102' then select gl101 from trialbalance
end
from trialbalance tb,Aging ag where ag.loc = tb.loc
但它不工作。
提前致谢。