[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

05/08/2007 at 07:51PM PDT, ID: 22560678
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.4

How to port an Access query using the PIVOT command to MSSQL?

Asked by sdamiano in Databases Miscellaneous, SQL Query Syntax, MS SQL Server

Tags: pivot, command, mssql

I have the following query in Access that uses two tables (a Fund table storing Mutual fund information and a ReturnPoint table storing monthly returns for each fund, they are linked by the Fund ID) and a PIVOT command on the Date field:

TRANSFORM Sum(dbo_tblReturnPoint.Return) AS SumOfReturn
SELECT dbo_tblFund.ID
FROM dbo_tblFund INNER JOIN dbo_tblReturnPoint ON dbo_tblFund.ID = dbo_tblReturnPoint.FundID
WHERE (((dbo_tblFund.ID)<5) AND ((dbo_tblReturnPoint.Date)>#1/31/2006#))
GROUP BY dbo_tblFund.ID
PIVOT dbo_tblReturnPoint.Date;

The output produced by the query consists of a matrix with the Fund Ids on the first column,
the return dates on the first row and the return values inside as shown below
(if a fund returns is missing on a particular date, the cell is blank):

ID      1/31/2006      2/28/2006      3/31/2006      4/30/2006      5/31/2006      6/30/2006      7/31/2006      8/31/2006      9/30/2006      10/31/2006      11/30/2006      12/31/2006      1/31/2007      2/28/2007      3/31/2007
1      0.0181905      0.0033673      0.007551      0.0076795      -0.0006427      0.0028      0.0038      0.0003      0.0032      0.0155      0.009941782      0.008513657      0.024973619      0.0045      
2      0.0027      0.0029      -0.003      -0.0059      -0.0184      0.0027      0.002936      -0.005044      -0.007826      -0.019376      -0.000042      0.010312      0.0116            
3      0.0076272      0.0263006      -0.0735671      -0.0312373      0.0177      -0.0116      -0.0807      0.0704      0.0767      0.0536      0.0009      0.0487      0.0034      0.012      
4      0.0641      0.012      0.0469      0.0066      -0.0581      -0.020400001      -0.0903      0.0317      0.0198      0.0118      0.069399998      -0.0106      0.057      -0.034      0.023

My question is: how do I port the above query to MSSQL where the PIVOT command doesn't exist?

Thanks,
Stefano
[+][-]05/08/07 07:56 PM, ID: 19054415

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Databases Miscellaneous, SQL Query Syntax, MS SQL Server
Tags: pivot, command, mssql
Sign Up Now!
Solution Provided By: DireOrbAnt
Participating Experts: 2
Solution Grade: B
 
 
[+][-]05/08/07 08:01 PM, ID: 19054429

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/09/07 01:55 AM, ID: 19055458

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20090824-EE-VQP-74