1. We have moved to a new forum! There may be a few things not working properly so please let us know if you find a bug. Remember to use the bbCode [ sql ] tag for SQL statements.

How can I select a Field and then add that field as a column?

Discussion in 'SQL - Questions and Answers' started by Sat, Jan 9, 2007.

  1. Sat Guest

    Dialect: SQL 92
    I have a table eg

    employee type value
    001 salary 1500.23
    001 expenses 120.00
    002 salary 1600.50
    003 salary 1600
    003 bonus 300

    And want the table to look like

    Employee salary expenses bonus
    001 1500.23 120 0

    Any ideas

    Thanks
  2. Dimitar Guest

    Hi Sat,

    From a discussion I had with a friend of mine:
    What you need is called a pivot table. I do not think it can be achieved with SQL92.
    I think however that some database servers have proprietary extensions for this
    e.g. the PIVOT statement in SQL 2005 (MS SQL), and I think Oracle also has the functionality.

    Dimitar

Share This Page