Columns to Rows

This section presents techniques for transforming a single row of data with values in multiple columns, like this one

KEY C1    C2    C3
--- ----- ----- -----
r1  v1    v2    v3
 

into multiple rows with values in a single column, like this.

KEY SOURCE VAL
--- ------ -----
r1  C1     v1
r1  C2     v2
r1  C3     v3
 

Tags

unpivot pivot columns to rows
collapse columns into rows merge columns
combine multiple columns into one column



Linking to SQL Snippets ™

To link to this page in Oracle Technology Network Forums or OraFAQ Forums cut and paste this code.

  • [url=http://www.sqlsnippets.com/en/topic-12027.html]SQL Snippets: SQL Techniques Tutorials - Columns to Rows[/url]

To link to this page in HTML documents or Blogger comments cut and paste this code.

  • <a href="http://www.sqlsnippets.com/en/topic-12027.html">SQL Snippets: SQL Techniques Tutorials - Columns to Rows</a>

To link to this page in other web sites use the following values.

  • Link Text : SQL Snippets: SQL Techniques Tutorials - Columns to Rows
  • URL (href): http://www.sqlsnippets.com/en/topic-12027.html