Solved

SQL in Oracle

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious sideā€¦
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

743 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

11 Experts available now in Live!

Get 1:1 Help Now