Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 YTD SUM

Author  Topic 

rv369
Starting Member

1 Post

Posted - 2014-02-11 : 17:03:59
I am trying to create a view for payroll the creates a YTD column for fields like gross wages. i have a separate row for every pay period but need to figure out how to SUM the gross wages by pay period and by employee. Any suggestions?

Robert Vesco

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2014-02-23 : 11:42:53
Post some sample data and expected result

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

maunishq
Yak Posting Veteran

71 Posts

Posted - 2014-02-25 : 14:11:05
in sql server 2012, you can do it by using windows function. SUM(SUM(gross_wages)) OVER (Partition by Pay_period, employee ORDER BY pay_period, employee)
in sql server 2008, you have to use subqueries and then sum them using those subqueries.


!_(M)_!
Go to Top of Page
   

- Advertisement -