Need Help On Query

  • Hi all

    I have a table with data like...

    ________________________

    FieldName | Field Value|

    --------------------------------

    StudentName | srikanth

    StudentName | kanth

    Qualification | MCA

    Qualification | B.SC

    Gender | Male

    Gender | Male

    Religion | Hindu

    Religion | Hindu

    --------------------------------

    i want to show this data like...

    ______________________________________________________________

    Student Name | Qualification | Gender | Religion |

    --------------------------------------------------------------

    Srikanth | MCA | Male | Hindu |

    kanth | B.sc | Male | Hindu |

    ---------------------------------------------------------------

    I have no idea to write the query, can any one help me. if u need more information feel free to ask.

  • I believe you are using 2005 because you posted in 2005 forum so check the Pivot and unpivot ...

    SQL Server 2005 Books Online 
    Using PIVOT and UNPIVOT

    http://msdn2.microsoft.com/en-us/library/ms177410.aspx

    http://www.devx.com/dbzone/Article/28165

     

     

    MohammedU
    Microsoft SQL Server MVP

  • Unless I've missed something in your question the query is straight forward:

    Select * from [tablename]

    That will return the data from the table, listed row after row with the column names horizontal across the screen and the column values running vertically down the screen.

    HTH,

    James.

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

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