In Oracle, the column-to-row function is the "unpivot()" function, which is used to convert table data from column to row. The syntax is "unpivot(custom column name column value for custom column Name column name in (column name))".
The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.
Oracle’s column-to-row function is the unpivot() function
The example is as follows:
Original table
with temp as( select '四川省' nation ,'成都市' 第一,'绵阳市' 第二,'德阳市' 第三,'宜宾市' 第四 from dual union all select '湖北省' nation ,'武汉市' 第一,'宜昌市' 第二,'襄阳市' 第三,'' 第四 from dual ) select nation,name,title from temp unpivot (name for title in (第一,第二,第三,第四))t
Description: unpivot(custom column name/*column value*/ for custom column name/*column name*/ in (column name))
The example is as follows:
The original data is as follows:
And the result I want to get is as follows:
##SQL:select class_name, student_name, course_type, result, created_date from class_tmp unpivot(result for course_type in(chinese_result,math_result));
Oracle Video Tutorial"
The above is the detailed content of What is Oracle's column to row function?. For more information, please follow other related articles on the PHP Chinese website!