oracle:递归统计(多字段)

源数据表

ID NAME PID VALUE1 VALUE2 VALUE3
1 0 1 2 3
2 1 10 20 30
3 2 100 200 300

sql语句

select sum(t.value1) || ',' || sum(t.value2) || ',' || sum(t.value3)
from test t
connect by prior t.id = t.pid
start with t.id = 1

结果

sum(t.value1) || ',' || sum(t.value2) || ',' || sum(t.value3)
111,222,333

猜你喜欢

转载自blog.csdn.net/m0_38084243/article/details/84975133