【发布时间】:2019-03-19 09:40:00
【问题描述】:
以下查询:
select coalesce(to_number(bl.division_code), bud.division) division
, coalesce(bud.glaccountcode, bl.costcenter_costanalysis_period_periods_year_years_balance_code_attr) glaccountcode
, coalesce(bud.costcenter, bl.costcenter_code_attr) costcenter
, coalesce(bud.costunit, bl.code_attr) costunit
, coalesce(bud.reportingyear, bl.costcenter_costanalysis_period_periods_year_reportingyear_attr) reportingyear
, coalesce(bud.reportingperiod, bl.costcenter_costanalysis_period_reportingperiod_attr) reportingperiod
, case when bud.amountdc > 0 then 456 else null end budgetamountdc label 'Budget (anonymized, EUR)'
, case when bl.balance > 0 then 123 else null end actualsamountdc label 'Actuals (anonymized, EUR)'
, case
when bl.division_code is null
then 'budget'
when bud.division is null
then 'balancelines'
else 'both'
end
label 'Source'
from exactonlinexml..balancelinesperperiodcostanalysis bl
full
outer
join exactonlinerest..budgets bud
on bud.division = to_number(bl.division_code)
and bud.glaccountcode = bl.costcenter_costanalysis_period_periods_year_years_balance_code_attr
and bud.costcenter = bl.costcenter_code_attr
and bud.costunit = bl.code_attr
and bud.reportingyear = bl.costcenter_costanalysis_period_periods_year_reportingyear_attr
and bud.reportingperiod = bl.costcenter_costanalysis_period_reportingperiod_attr
将总帐帐户上的实际交易与相关预算详细关联起来:
- 确切的在线公司 (
division_code) - 财政年度 (
reportingyear) - 财务期(
reportingperiod) - 总帐帐户 (
glaccountcode) - 成本中心 (
costcenter) - 成本单位 (
costunit)
我希望这些维度的每个组合最多有一行数据。但是,对于某些组合,将返回 2 行。其中一行有一个标签“预算”,而另一行有一个“平衡线”。
似乎它们没有在合并中合并在一起:
2019年第1期余额行中gl账户5050的内容为一行,有一定金额(不等于0)。
2019年第1期预算中GL账户5050的内容也是一行,有一定金额(不等于0)。
我似乎无法找到为什么行没有通过完全外连接和合并合并在一起。
我做错了什么?
【问题讨论】:
标签: exact-online invantive-sql