We help IT Professionals succeed at work.

I see years - I wanted to see the sum of  SumOfAmount in rows and columns and years as column headings - what am I doing wrong?

271 Views
Last Modified: 2012-05-11
Select Job, 2003,2004,2005,2006,2007,2008,2009,2010,2011
FROM (
SELECT Job,datepart(year,Acedata.Date) as nYears,
(InCredit+OutDebit) AS SumOfAmount
FROM AceData
)
ps PIVOT(
SUM (SumOfAmount)
FOR nYears IN( [2003],[2004],[2005],[2006],[2007],[2008],[2009],[2010],[2011])
  ) AS pvt

my table is simple,
it has columns
 date,job,incredit,outdebit

I am using mssql 8 express
Comment
Watch Question

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
timely and correct!!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.