在Oracle中将列转换为行

在Oracle中将列转换为行

问题描述:

我有一张表,该表有两列first_name,last_name,其中一行是john mathew.我希望结果以john的形式出现,而下一行是mathew.

I have a table with two columns first_name, last_name, with one row as john mathew. I want result as john in one row and mathew in next row.

FNAME   LNAME
-------------
JOHN    METHEW

结果为

Name
-----
JOHN
METHEW

简而言之,想将列转换为行.

In short want to convert column to rows.

SELECT name
  FROM pivot_test
UNPIVOT ( name FOR origin IN (fname, lname) )

SQL小提琴