PIVOT Clause
The PIVOT clause is used to cross-tabulation clauses i.e. clauses modifying rows to become.
Syntax:
SELECT * FROM
(
SELECT col1, col2,..., colN
FROM col1, col2,..., colN
[WHERE condition]
)
PIVOT
(
agg_func(col)
FOR col
IN ( expr1, expr2, ... exprN )
)
[ORDER BY expression [ ASC | DESC ]];
Parameters:
- condition: Optional filtering conditions for the data.
- agg_func: The aggregation function to use.
- col: The column whose values are to be used in the pivot clause.
- expr1, expr2, … exprN: Expressions defining values for the columns used in the pivot.
- expression: An optional expression used to order the final output data.
We will look at an example in the following sections.
How Efficiently Convert Rows to Columns in PL/SQL?
PL/SQL, or Procedural Language/Structured Query Language, is an extension of SQL used for writing procedural code within Oracle databases. It is a proprietary procedural extension of SQL developed by Oracle Corporation specifically for Oracle Database.
It combines the power of SQL with procedural constructs like loops, conditions, and exception handling. It is a blocked programming language, programming units can be named or unnamed blocks. Unnamed blocks are never stored in the database.
Contact Us