Professional Documents
Culture Documents
Pivot and Unpivot Operators in Oracle Database 11g1
Pivot and Unpivot Operators in Oracle Database 11g1
Pivot and Unpivot Operators in Oracle Database 11g1
Home Data Warehouse Informatica Informatica Scenarios Informatica Cloud Oracle Unix Hadoop
Search... Search
Pivot and Unpivot Operators in Oracle Database 11g
Pivot:
Popular Posts
2 A 30
SQL Queries Interview Questions - Oracle Part 1
2 B 40
2 C 50 Design/Implement/Create SCD Type 2 Effective Date
3 A 60 Mapping in Informatica
3 B 70
Top Unix Interview Questions - Part 1
3 C 80
Grep Command in Unix and Linux Examples
The rows of the "sales" table needs to be converted into columns as shown below
vijay bhaskar
Add to circles
The query for converting the rows to columns is
SELECT *
FROM (SELECT customer_id,product,price from sales)
pivot ( sum(price) as total_price for (product) IN ( 'A' as a, 'B' as b, 'C'
Pivot can be used to generate the data in xml format. The query for generating the data into xml
fomat is shown below.
SELECT *
FROM (SELECT customer_id,product,price from sales)
pivot XML ( sum(price) as total_price for (product) IN ( SELECT distinct prod
994 have me in circles View all
If you are not using oracle 11g database, then you can implement the unpivot feature as
converting rows to columns
Unpivot:
https://www.folkstalk.com/2011/12/pivot-and-unpivot-operators-in-oracle.html 2/4
11/29/2018 Pivot and Unpivot Operators in Oracle Database 11g
SELECT *
FROM sales_rev
UNPIVOT [EXCLUDE NULLs | INCLUDE NULLs] (price FOR product IN (a_product AS '
2 comments:
https://www.folkstalk.com/2011/12/pivot-and-unpivot-operators-in-oracle.html 3/4
11/29/2018 Pivot and Unpivot Operators in Oracle Database 11g
Reply
Replies
Reply
Publish Preview
https://www.folkstalk.com/2011/12/pivot-and-unpivot-operators-in-oracle.html 4/4