SELECT id, parent FROM
RollupAccount where id = 1000
SELECT R.id, R.parent FROM
RollupAccount AS R JOIN
[Rollup] AS RP ON R.parent = RP.ID
SELECT SUM(balance) AS Balance
FROM DetailAccount AS D
JOIN
[Rollup] AS R ON
R.id = D.parent
Rollup CTE
a
b
c
d
