SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 New Topic  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

22847 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  
 New 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.08 seconds. Powered By: Snitz Forums 2000