Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL in Oracle

Posted on 2014-01-20
2
Medium Priority
?
413 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
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.

609 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