SALFLDGAMS Table:
Acc_Code Period Amount
11500 2000 234
11511 2000 345
11500 2000 223
NewView:
Acc_Code Period BeginBalance
11500 2001 457
I want a new view based on the SALFLDGAMS table that shows the begin balance for example 2001 that comes from the total amount Sum of 2000.
|||Hello there:
SELECT Acc_code, CONVERT(int, Period) + 1 AS PeriodNext, SUM(Account) AS PreBalance
FROM dbo.myAccount
GROUP BY Acc_code, Period
From reading your other questions about this, you can modify your query to reach your goal.
Suppose your period column is Varchar column in this format: 20020101
SELECT Acc_code, (CONVERT(int, Left(Period,4)) + 1) AS PeriodNext, SUM(Account) AS PreBalance
FROM dbo.myAccount
GROUP BY Acc_code, Period