pivoting feature

  • 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 ????

  • 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]

    SQL-4-Life
  • 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


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

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

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