Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Pivot Query

Posted on 2013-01-29
1
Medium Priority
?
327 Views
Last Modified: 2013-01-30
Please see attached ON the DATABASE TABLE TAB.  This is my source DATA.
Please see attached ON the How it Should look TAB.  
Mapping FROM the DATABASE TABLE
Occurence = Wall

COLUMN 1 = The multiplier WHERE Priority=1 FROM the databasetable
COLUMN 2 = The multiplier WHERE Priority=2 FROM the databasetable

Please see attached ON the What Query returns tab

This is not what I want.  I need TO PIVOT the priority As the columns AND THEN DROP the multiplier VALUES IN each COLUMN according TO priority

Here is my query.  Can someone please take a look and tell me what I should do to make this work.  If possible, could you provide some code.  

Thanks.


select Occurence AS Wall, Multiplier, [1], [2]
from (
      select Occurence, Multiplier,Priority, row_number() over (partition by Occurence ORDER BY Occurence) rn
      from tblCadenceStrategydetails_test
) o
pivot(Max(Priority) for rn in ([1], [2])) p
ORDER BY Occurence


I am really in a bind to get this working.  Any help would be greatly appreciated.
pivotquestion.xlsx
0
Comment
Question by:sherbug1015
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 25

Accepted Solution

by:
chaau earned 2000 total points
ID: 38833480
This is what you are after:

select Occurence AS Wall, [1], [2]
from (
      select Occurence, Multiplier, Priority
      from tblCadenceStrategydetails_test
) o
pivot(MAX(Multiplier) for Priority in ([1], [2])) p
ORDER BY Occurence

Open in new window


SQL Fiddle
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question