Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7407237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:40:57+00:00 2026-05-29T05:40:57+00:00

I need to turning the value of a row into column – for example:

  • 0

I need to turning the value of a row into column – for example:

SELECT s.section_name, 
       s.section_value 
  FROM tbl_sections s

this outputs :

section_name   section_value
-----------------------------
sectionI       One
sectionII      Two
sectionIII     Three

desired output :

sectionI      sectionII      sectionIII
-----------------------------------------
One           Two            Three
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:40:58+00:00Added an answer on May 29, 2026 at 5:40 am

    This is probably better done client-side in the programming language of your choice.

    You absolutely need to know the section names in advance to turn them into column names.

    Updated answer for Oracle 11g (using the new PIVOT operator):

    SELECT * FROM 
      (SELECT section_name, section_value FROM tbl_sections)
    PIVOT
      MAX(section_value) 
        FOR (section_name) IN ('sectionI', 'sectionII', 'sectionIII')
    

    For older versions, you could do some self-joins:

    WITH
      SELECT section_name, section_value FROM tbl_sections
    AS 
      data
    SELECT
       one.section_value 'sectionI', 
       two.section_value 'sectionII', 
       three.section_value 'sectionIII'
    FROM 
       select selection_value from data where section_name = 'sectionI' one
      CROSS JOIN
       select selection_value from data where section_name = 'sectionII' two
      CROSS JOIN
       select selection_value from data where section_name = 'sectionIII' three
    

    or also use the MAX trick and “aggregate”:

    SELECT 
       MAX(DECODE(section_name, 'sectionI', section_value, '')) 'sectionI',
       MAX(DECODE(section_name, 'sectionII', section_value, '')) 'sectionII',
       MAX(DECODE(section_name, 'sectionIII', section_value, '')) 'sectionIII'
    FROM tbl_sections
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help in turning this linq expression into a linq statment. SampleData.Publishers and
I need help turning something like: <img class=coup-pic src=http://example.com/img/pic.jg alt= /> into: <a href=http://example.com/img/pic.jg><img
i need some help with inserting multiple rows from different arrays into my database.
I thought this was going to be easy, but it's turning into quite a
So I need some way of turning given Protocol://URLorIP:Port string into string ip int
hi im pretty much a beginner.I need some help turning this script in an
Need to insert selected text on the page into textarea. There must be some
I need to derive an important value given 7 potential inputs . Uncle Bob
From what I can tell from reading everything I can find here, this doesn't
I had a straight forward approach of turning Key/Value pairs of an XML excerpt

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.