if SQL SERVER 2012 (you didn't post your version):SELECT report_year as "@date",'Q'+CAST(report_quarter+1 as varchar(1)) as "@quarter", SUM(a.balance) as "@balance", SUM(a.interest_payment) as "@interest_payment", FIRST_VALUE(balance) over(partition by report_quarter order by reporting_date)FROM ( SELECT *, (reporting_date%100 - 1)/3 as report_quarter, reporting_date/100 as report_year FROM employee) aGROUP by report_year, report_quarterorder by report_year, report_quarter