Advertisement

05.02.2008 at 06:45PM PDT, ID: 23373351
[x]
Attachment Details

Collapse Query Results into single row

Asked by tbaseflug in MS SQL Server

Tags: SQL Server 2005

I have the following query - which produces 3 columns, one valid value in each col and the others with a NULL value - would like to collapse all of the rows into a single row:Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
SELECT  DISTINCT MarketIndicator,
NonMarketRate,
MarketInflator
 FROM (
 SELECT  DISTINCT 
        [2].IterationID,
        [1].DB AS IterationDB,
CASE WHEN [2].IterationValue = 'Average' THEN [2].IterationValue
WHEN [2].IterationValue = 'Midpoint' THEN [2].IterationValue ELSE NULL END AS [MarketIndicator],
CASE WHEN [2].IterationValue = 'RaiseNonMarketItems' THEN CONVERT(varchar(10),[2].IterationRate) END AS [NonMarketRate],
CASE WHEN [2].IterationValue = 'MarketInflator' THEN CONVERT(varchar(10),[2].IterationRate) END AS [MarketInflator]
    FROM
        dbo.Pricing_tblIteration AS [1] INNER JOIN
        dbo.Pricing_tblIterationDetail AS [2] ON [1].ID = [2].IterationID
    WHERE
        IterationID = 31) a
 
Loading Advertisement...
 
[+][-]05.02.2008 at 06:48PM PDT, ID: 21490978

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.02.2008 at 06:50PM PDT, ID: 21490981

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.02.2008 at 06:54PM PDT, ID: 21490991

View this solution now by starting your 7-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

Zone: MS SQL Server
Tags: SQL Server 2005
Sign Up Now!
Solution Provided By: Thomasian
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628