Dybest set kunne du tage dette svar og skift blot en af joinbetingelserne:
SELECT
f.TimeKey,
s.AccountKey,
SUM(f.Debit) AS Debit,
SUM(f.Credit) AS Credit
FROM DimAccounts s
INNER JOIN DimAccounts b ON b.AccountCode LIKE s.AccountCode + '%'
/* alternatively: ON s.AccountCode = LEFT(b.AccountCode, LEN(s.AccountCode)) */
INNER JOIN FactBudget f ON f.AccountKey = b.AccountKey
WHERE s.AccountType = 'S'
AND b.AccountType = 'B'
GROUP BY
f.TimeKey,
s.AccountKey