April 14, 2011 at 1:33 am
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
.
.
.
.
April 14, 2011 at 1:51 am
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]
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply