付款
Year Month Division Department Payments_received_Count
------------------------------------------------------------------------
2016 1 Electric dep1 2
2016 1 Electric dep2 3
2015 1 Electric dep1 1
司
Division Department
--------------------------------
Electric Dep1
Electric Dep2
Electric Dep3
如何加入表格以获得以下结果?
Year Month Division Department Payments_received_Count
------------------------------------------------------------------------
2016 1 Electric dep1 2
2016 1 Electric dep2 3
2016 1 Electric dep3 0
2015 1 Electric dep1 1
2015 1 Electric dep2 0
2015 1 Electric dep3 0
因此,对于每年和每月,我必须使用分部表加入付款表。请提出一个方法。
我知道CASE WHEN
会在这种情况下有所帮助,但我找不到正确的方法。
CASE Payments_received_Count
WHEN null THEN 0
ELSE Payments_received_Count
由于
答案 0 :(得分:2)
您需要部门/部门和年/月的组合。首先,使用ScrollArea
生成行。然后使用cross join
获取值:
left join