October 2, 2007 at 3:34 am
hello guys !!!
i have a table as
id date data
1 3/10/2007 "hello"
1 4/10/2007 "hi"
2 3/10/2007 "hello"
2 4/10/2007 "why"
i need the output like
id 3/10/2007 4/10/2007
1 "hello" "hi"
2 "hello" "why"
I know about the sql server pivot command, but in that, one has to specify max, min, count etc. i dont need to apply any formula, i just need the straight way value for that particular date.
Any idea ????
October 2, 2007 at 4:50 am
Hi,
have you tried this:
SELECT
ID
,[2007-10-03] as [2007-10-03]
,[2007-10-04] as [2007-10-04]
FROM
(
SELECT
ID
,ID as [tmp]
,DATE
,[DATA]
FROM MyTable
) p
PIVOT(MAX([DATA])
FOR DATE in ([2007-10-03],[2007-10-04])
) as pv
thanks
Chris
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
October 2, 2007 at 4:57 am
Pivots perform a group by, so they must use an aggregate. If the data is the same though, or there is only one item, using max or min solves the problem.
Andras
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply