to show row wise data into column wise

  • hello,

    my requirment is that i have 5 rows of data but i want to show it as clomun

    ex:i have like this

    rows

    jack

    mack

    peter

    scott

    steve

    i need this type

    columns

    jack mack peter scott steve

  • Basically, there are two ways for this common requirement:

    one is the PIVOT function (see BOL = BooksOnLine, the SQL help system, for details) and the other option uses the CASE statement.

    The latter can be used if the number of target columns is not static.

    For details please review the following two articles by Jeff Moden:

    Cross Tabs[/url] and

    Dynamic Cross Tabs[/url].



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • syed_ahmedzama (8/17/2009)


    hello,

    my requirment is that i have 5 rows of data but i want to show it as clomun

    ex:i have like this

    rows

    jack

    mack

    peter

    scott

    steve

    i need this type

    columns

    jack mack peter scott steve

  • syed_ahmedzama (8/17/2009)


    hello,

    my requirment is that i have 5 rows of data but i want to show it as clomun

    ex:i have like this

    rows

    jack

    mack

    peter

    scott

    steve

    i need this type

    columns

    jack mack peter scott steve

    This is a form of denormalization that should probably never be used. Why do you need to do this? What are the business rules that require this? I always ask this because there may be a better way.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

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

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