Solved

SQL in Oracle

Posted on 2014-01-20
2
403 Views
Last Modified: 2014-01-20
Hello Experts,

I have the below table :


CREATE TABLE sr_t 
(col1 VARCHAR2(2000),
col2 VARCHAR2(100) ,
col3 VARCHAR2(100)  );

Open in new window



Data as below:

INSERT INTO sr_t VALUES('Team 1' , 1 , 'TEAM');
INSERT INTO sr_t VALUES('Team 2' , 2 , 'TEAM');
INSERT INTO sr_t VALUES('Grp 1' , 1 , 'GROUP');
insert into sr_t values('Grp 2' , 2 , 'GROUP');

Open in new window


Now when we run the SQL :

SQL> SELECT * FROM sr_t;

I get the below result:

Result
But I want the result as like below:

TEAM	GROUP	COL2
Team 1	Grp 1	1
Team 2	Grp 2	2

Open in new window

0
Comment
Question by:Swadhin Ray
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 39793826
I think this would do, doing some assumptions;
select t.col1 TEAM, g.col1 "GROUP", t.col2
  from   sr_t t
  join  sr_t g
    on t.col2 = g.col2
   and g.col3 = 'GROUP'
  and t.col3 = 'TEAM' 

Open in new window

0
 
LVL 16

Author Closing Comment

by:Swadhin Ray
ID: 39793894
thanks
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question