Solved

SQL in Oracle

Posted on 2014-01-20
2
404 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

691 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