Problem with query???

  • Hi,

    I have a table that looks like this:

    Table1:

    ID - int

    Type - nvarchar(50),

    Date - DateTime,

    Value - nvarchar(50)

    I wanna make a query where i'll get some results for specific date, but the problem is that i want the values for difrent types. Something like this:

    SELECT [Value1_Type1], [Value2_Type2], [Value3_Type3], [Value4_Type4], [Value5_Type5]

    FROM Table1

    WHERE Date = .....

    So, [Value1_Type1] is the value for some specific type, [Value2_Type2] is the value for some other type, [Value3_Type3]............

    My question is: How can i get this values without making many queris like

    SELECT [Value1_Type1]

    FROM Table1

    WHERE Date = ..... AND Type = Type1

    SELECT [Value2_Type2]

    FROM Table1

    WHERE Date = ..... AND Type = Type2

    .

    .

    .

    .

  • Look up Pivot.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns[/url]

    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs[/url]

    If you want more help, please provide readily consumable test data[/url]


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply