The table employee contains 10 records with the employees details (Name, salary, role and year of reference)
SELECT * FROM EMPLOYEE
With the Pivot operator we can easily generate a crosstab.
SELECT *
FROM (SELECT YEAR,
EMP_SALARY,
EMP_ROLE
FROM EMPLOYEE)
PIVOT (SUM(EMP_SALARY)
FOR EMP_ROLE IN ('Manager' AS MANAGER,
'Seller' AS SELLER ,
'Cashier' AS CASHIER)
)
Here the result below
Have a nice Pivot
No comments:
Post a Comment