PIVOT Syntax HELP....!


Can someone eyeball this SQL which uses PIVOT and help me with the error? It works find until I try to ADD more that ONE field to the SUM in the PIVOT..???

--Weekly Reserve Data
select distinct Portfolio_wk
 , count( [Orderid]) as OrderCount
 , sum(case when [Customer?] = 'Customer' then 1 else 0 end) as CustomerCount
 , [1] as [2008-10-20]
 , [2] as [2008-10-27]
 , [3] as [2008-11-03]
 , [4] as [2008-11-10]
 , [5] as [2008-11-17]
 , [6] as [2008-11-24]  -- <== Add weeks here to increase the columns
  (select portfolio_wk,orderid, customerid, isnull(cogsamount,0) as cogsamount, [customer?], cogswp, cogsrca from dbo.reserve) r
(sum(cogsamount) for cogsamount  in ([1],[2],[3],[4],[5],[6]))  -- <--THIS WORKS
(sum(cogsamount + cogswp + cogsrca) for cogsamount  in ([1],[2],[3],[4],[5],[6])) -- <--THIS DOES NOT
as pvt
group by portfolio_wk, pvt.[1], pvt.[2], pvt.[3], pvt.[4], pvt.[5], pvt.[6]

Basically I need to have a SUM of the 3 columns cogsamount, cogswp, cogsrca


LVL 17
MIKESoftware Solutions ConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MIKESoftware Solutions ConsultantAuthor Commented:
ooops...sorry here is the error:

Msg 102, Level 15, State 1, Line 15
Incorrect syntax near '+'.
MIKESoftware Solutions ConsultantAuthor Commented:
I forgot to comment out ONE of those lines referenced..but hopefully you'll understand what i mean....

How do I combine 3 columns of data and SUM them for the PIVOT...???
SharathData EngineerCommented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.