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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:01:42+00:00 2026-05-15T10:01:42+00:00

I have a table in Oracle 10g that contains some information as follows: SQL>

  • 0

I have a table in Oracle 10g that contains some information as follows:

SQL> select * from t_test;

      INFO     CODIGO GRUPO
---------- ---------- ----------
       101        190 VTOS
       100        130 VTOS
       102        140 VTOS

I’d like to extract all the rows that have GRUPO=’VTOS’ and transpose those rows to columns. The values in CODIGO are predetermined(I know which values can be stored in that column), so would like to get something like this:

INFO_190 INFO_130 INFO_140
-------- -------- --------
     101      100      102

I know I can do it with some subqueries, for example:

SELECT (SELECT info
          FROM t_test
         WHERE codigo = 190 AND grupo = 'VTOS') info_190,
       (SELECT info
          FROM t_test
         WHERE codigo = 130 AND grupo = 'VTOS') info_130,
       (SELECT info
          FROM t_test
         WHERE codigo = 140 AND grupo = 'VTOS') info_140
  FROM DUAL

but I’d like to find a more efficient way. Can anyone suggest how to do it?

  • 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-15T10:01:43+00:00Added an answer on May 15, 2026 at 10:01 am

    Assuming you have a relatively small number of codigo values, something like the following should work:

    select max(decode(codigo, 190, info, '')) info_190,
     max(decode(codigo, 130, info, '')) info_130,
     max(decode(codigo, 140, info, '')) info_140
    from t_test
    where grupo = 'VTOS';
    

    If you have multiple grupo values, group by grupo and include it in your select clause.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Oracle 10g table that contains a # of log records. This
I'm using SQL*Plus 9.2 on Oracle 10g enterprise. I have created some scripts that
I have an application that records activity in a table (Oracle 10g). The logging
I have created a table in Oracle 10g and trying to insert some rows
I have created a table on an Oracle 10g database with this structure :
I have table A in Oracle that has a primary key (id). I need
I have an Oracle table which contains event log messages for an application. We
I have an oracle table with a column from type SYS.XMLTYPE and a storage
we have a table in an Oracle Database which contains a column with the
I have a hierarchical table on Oracle pl/sql. something like: create table hierarchical (

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.