Home > Database > Oracle > What is the column transfer function in oracle

What is the column transfer function in oracle

青灯夜游
Release: 2021-12-24 15:13:58
Original
3490 people have browsed it

The column transfer function in oracle is "pivot()". The function of this function is to convert rows into columns. The syntax "pivot (any aggregate function for the column name of the value of the special column in (needs to be converted is the value of the column name))".

What is the column transfer function in oracle

The operating environment of this tutorial: Windows 7 system, Oracle 11g version, Dell G3 computer.

The column transfer function in oracle is "pivot()".

pivot function: row to column function

Syntax:

pivot(任一聚合函数 for 需转列的值所在列名 in (需转为列名的值));
Copy after login

Conversion example:

1 , Original table data:

sql statement: select * from T_PIVOT_TEST_1;

What is the column transfer function in oracle

##2. Use the pivot function to convert rows to columns. The aggregate function is used to evaluate the data column, and the values ​​'COL_1', 'COL_2', and 'COL_3' in the th column are converted into column names, and aliases are added to them.

sql statement:

select * from T_PIVOT_TEST_1
pivot (sum(er) for th in ('COL_1' as 第一列,'COL_2'as 第二列 ,'COL_3' as 第三列));
Copy after login
Result diagram after conversion:

What is the column transfer function in oracle## Recommended tutorial: "

Oracle Tutorial

"

The above is the detailed content of What is the column transfer function in oracle. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template