pivot table query

Hi experts, attached is how I want the original table data to be transformed to the pivot table, pls suggest the query for this,. thanks
Copy-of-PivotTable.xlsx
sqlcuriousAsked:
Who is Participating?

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

x
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.

Patrick MatthewsCommented:
Some questions:
1) Is RowNum an actual column in the table?
2) If so, how is it generated?  For example, is it a sequence number for the tale as a whole, or does it restart at 1 for each customer?
3) Did you mean to handle the Value, ImagePath, and Description columns the way you did in the example?
4) What would you expect to see if a given customer had, say, 47 different items in the original table?
0
sqlcuriousAuthor Commented:
Hi Patrick, Sorry about not giving further details in the original post.
RowNum is actual column, it does start with 1, this is generated by a different process and every customers will have only 3 items, so there wont be a question of 47 different items
About your pointer 3, I am sorry about the data , it got skewed while copying, my intention was to remove value field completely since I don't need it in the new table, attached is a much relevant one.
Thanks!
Copy-of-PivotTable.xlsx
0
PortletPaulEE Topic AdvisorCommented:
A query like this should do the trick:
select
      1 as RowValue	
    , Customer_No
    , MAX(EmailAddress) as EmailAddress
    , max(case when RowNum = 1 then Inventory_No end) as Inventory_No1	
    , max(case when RowNum = 1 then Sale_No      end) as Sale_No1	
    , max(case when RowNum = 1 then Lot_No       end) as Lot_No1	
    , max(case when RowNum = 1 then Venue        end) as Venue1	
    , max(case when RowNum = 1 then PCGS_No      end) as PCGS_No1	
    , max(case when RowNum = 1 then Grade        end) as Grade1	
    , max(case when RowNum = 1 then Service      end) as Service1	
    , max(case when RowNum = 1 then ImagePath    end) as ImagePath1	
    , max(case when RowNum = 1 then Description  end) as Description1	

    ... repeat similar block for rownum 2 and 3

from your_table
GROUP BY
    Customer_No

Open in new window


HOWEVER you do NOT want to, or need to, repeat Customer_No 3 times!
0

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
Vitor MontalvãoMSSQL Senior EngineerCommented:
sqlcurious, do you need more help on this question?
0
sqlcuriousAuthor Commented:
excellent! thanks
0
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 2008

From novice to tech pro — start learning today.