Solved

SQL in Oracle

Posted on 2014-01-20
2
400 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
2 Comments
 
LVL 142

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
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.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

919 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now