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

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

rv369
Starting Member

USA
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

madhivanan
Premature Yak Congratulator

India
22713 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

Madhivanan

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

maunishq
Yak Posting Veteran

Canada
66 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.


!_(M)_!
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.05 seconds. Powered By: Snitz Forums 2000