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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 02/11/2014 :  17:03:59  Show Profile  Reply with Quote
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

Premature Yak Congratulator

22864 Posts

Posted - 02/23/2014 :  11:42:53  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Post some sample data and expected result


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

Yak Posting Veteran

71 Posts

Posted - 02/25/2014 :  14:11:05  Show Profile  Reply with Quote
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.

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000