Sql Server Pivot Table

Viewing 1 post (of 1 total)
  • Author
  • #3283

    A Pivot Table can automatically sort, count, and total the data stored in one table or spreadsheet and create a second table displaying the summarized data. The PIVOT operator turns the values of a specified column into column names, effectively rotating a table.

    Table stracture with table test:
    The Month colums contain the month number from 1 to 12.By the help of pivot table we can convert rows data into coulms.

    Pivot query:
    SELECT *
    SELECT name,MONTH,salary
    FROM test

    ) p
    sum (salary)
    FOR [month]
    IN ([1], [2], [3],[4], [5], [6],[7],[8],[9],[10],[11],[12])
    ) AS pvt;

    Result display by this query :

    try the example the you will understand the working of pivot table.

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.