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 9183177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:44:22+00:00 2026-06-17T18:44:22+00:00

If i start off with: SELECT * FROM unpivot_test; ID CUSTOMER_ID PRODUCT_CODE_A PRODUCT_CODE_B PRODUCT_CODE_C

  • 0

If i start off with:

SELECT * FROM unpivot_test;

         ID CUSTOMER_ID PRODUCT_CODE_A PRODUCT_CODE_B PRODUCT_CODE_C PRODUCT_CODE_D
 ---------- ----------- -------------- -------------- -------------- --------------
     1         101             10             20             30
     2         102             40                            50
     3         103             60             70             80             90
     4         104            100

and when i Unpivot i get the values

SELECT *
FROM   unpivot_test
UNPIVOT (quantity FOR product_code IN (product_code_a AS 'A', product_code_b AS 'B', product_code_c AS 'C', product_code_d AS 'D'));

        ID CUSTOMER_ID  P   QUANTITY
---------- ----------- --- ----------
     1         101     A         10
     1         101     B         20
     1         101     C         30
     2         102     A         40
     2         102     C         50
     3         103     A         60
     3         103     B         70
     3         103     C         80
     3         103     D         90
     4         104     A        100

What if i want to make it so that quantity column shows BEFORE the P column, how would i go about doing this, i basically want

        ID CUSTOMER_ID   QUANTITY    P
---------- ----------- -----------  ----------
     1         101     10           A
     1         101     20           B

…..

oracle version is 11g

  • 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-06-17T18:44:23+00:00Added an answer on June 17, 2026 at 6:44 pm
    SELECT ID, CUSTOMER_ID, QUANTITY, P FROM
    (SELECT *
    FROM   unpivot_test
    UNPIVOT (quantity FOR product_code IN (product_code_a AS 'A', product_code_b AS 'B',  
    product_code_c AS 'C', product_code_d AS 'D')));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets start off with a list of strings that will be used to filter
To start off, here is the JSON response that I've been working on: {
to start off, I know C++, C#, Python, some Ruby, and basic Javascript. Anyway,
I'll start off with a solid example: I have a function that generates hashes
Let me first start off, sorry for the confusing title. I didn't know how
Ok so to start off, I'm not using any sort of web service. Right
I need start off with code because I am not sure what terminology to
Let me start off by saying I don't want to print only the duplicate
First, I'll start off by saying that I do not have control over the
At work we use a branching strategy where all changes start off in a

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.