我有这张桌子。只有明细表获得价值;我想得到分支的总和。
ACCOUNT Value
---------- -------------
100
100-01
100-01-01
100-01-01-001 7
100-01-01-006 6
100-01-01-271 5
100-02
100-02-01-001 1
100-02-01-006 2
100-02-01-271 3
Run Code Online (Sandbox Code Playgroud)
喜欢
ACCOUNT Value
---------- -------------
100 24 -- (sum of 100%)
100-01 18 -- (sum of 100-01%)
100-01-01 18 --(sum of 100-01-01%)
100-01-01-001 7
100-01-01-006 6
100-01-01-271 5
100-02 6 -- (sum of 100-02%)
100-02-01-001 1
100-02-01-006 2
100-02-01-271 3
Run Code Online (Sandbox Code Playgroud)
我尝试通过 and 进行 sum 并尝试 sum(value) where account like account||'-%' 但不能结束