how to display the table content in column

  • hi friends,

    I'm having an Emp table with three column and three rows,

    Select * from Emp, I can get the Following result as below,

    Emp-idEmp-Name Dept

    1 John Phy

    2 Max Chem

    3 Jack Phy

    how can i achieve the following result using SQL Query to display result in column wise

    Emp-id 1 2 3

    Emp-Nam John Max Jack

    Dept Phy Chem Phy

    Thanks in Advance.

    windows_mss

    ___
    Known Is An Drop,Unknown Is An Ocean....
    Njoy Programming
    🙂

  • Need this really to be done by SQL.

    There are some easier ways to do this.

    Like OLAP or Reporting Services or just like MTRANS Function from Excel.

  • There's a thousand posts on this... search for "Convert rows to columns".

    Also, why do you want to do this? What if a Department has 1,000 employes? How would you display THAT?

    --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)

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

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