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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:34:55+00:00 2026-05-23T20:34:55+00:00

I have tables like this fake ones: data: id type month value 1 1

  • 0

I have tables like this fake ones:

data:
    id  type    month   value
    1   1       1       10
    2   1       2       20
    3   1       3       30
    4   2       1       40
    5   2       2       50
    6   2       3       60
    7   3       1       70
    8   3       2       80
    9   3       3       90
    10  4       1       100
    11  4       2       110
    12  4       3       120

type:
    id  name
    1   A
    2   B
    3   C
    4   D

What I want:
    month   valueA  valueB  valueC  valueD
    1       10      40      70      100
    2       20      50      80      110
    3       30      60      90      120

How can I make this query?
I’m using Oracle 10g.

  • 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-23T20:34:56+00:00Added an answer on May 23, 2026 at 8:34 pm

    It looks like you want a relatively straightforward pivot of the data. If you were using 11g, you could use the more elegant PIVOT function. But in 10g, you could still do something like this

    SQL> ed
    Wrote file afiedt.buf
    
      1  with data as (
      2    select 1 id, 1 type, 1 month, 10 value from dual union all
      3    select 2,1,2,20 from dual union all
      4    select 3,1,3,30 from dual union all
      5    select 4,2,1,40 from dual union all
      6    select 5,2,2,50 from dual union all
      7    select 6,2,3,60 from dual union all
      8    select 7,3,1,70 from dual union all
      9    select 8,3,2,80 from dual union all
     10    select 9,3,3,90 from dual union all
     11    select 10,4,1,100 from dual union all
     12    select 11,4,2,110 from dual union all
     13    select 12,4,3,120 from dual
     14  ),
     15  type as (
     16    select 1 id, 'A' name from dual union all
     17    select 2,'B' from dual union all
     18    select 3,'C' from dual union all
     19    select 4,'D' from dual)
     20  select d.month,
     21         max(case when t.name = 'A' then d.value else null end) valueA,
     22         max(case when t.name = 'B' then d.value else null end) valueB,
     23         max(case when t.name = 'C' then d.value else null end) valueC,
     24         max(case when t.name = 'D' then d.value else null end) valueD
     25    from data d,
     26         type t
     27   where d.type = t.id
     28*  group by d.month
    SQL> /
    
         MONTH     VALUEA     VALUEB     VALUEC     VALUED
    ---------- ---------- ---------- ---------- ----------
             1         10         40         70        100
             2         20         50         80        110
             3         30         60         90        120
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables like this: Person table: person_id | name | dob --------------------------------
I have two tables like this: TABLE user( id CHAR(100) text TEXT ) TABLE
I have two tables like this. Table1 Column | Type | ---------+------------------+ cod |
I have three tables like this: Person id | name | location ----------------------- 1
I have 2 tables like this: [people1]: |First Name*| Last Name*| | | |
I have Two tables like this: Table categories: columns: id, name, parent 1, Foods,
I have a tables like this Results ------- id - autoincrement value TestCase -
I have two tables like this: table a: [id, name, roll, address, mark] table
I have 3 tables like this player(id,name,age,teamid) team(id,name,sponsor,totalplayer,totalchampion,boss,joindate) playerdetail(id,playerid,position,number,allstar,joindate) I want to select teaminfo
I have two tables like this. Table 1 Fields: CId , Name Table 2

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.