Solved

Request a high efficient query

Posted on 2011-09-27
4
206 Views
Last Modified: 2012-06-21
Have a table T with the following data
T (c1 number(10), c2 varchar2(10))

c1    c2
1      B
1      C
2      A
3      D
4      A
4      A
5      A
5      B
6      C
6      A
6      D
7      E
8      B
8      C
....

Now want to get all C1 with only C2=A (single and duplicates). For the above example,

Want to get the records:
c1
2
4

Since C2 in all of the records are 'A', they are selected..

0
Comment
Question by:jl66
  • 2
4 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 450 total points
ID: 36713751
Try this:

Select c1 from table where c1='A'
Minus
Select c1 from table where c2 !='A';
0
 
LVL 16

Assisted Solution

by:Swadhin Ray
Swadhin Ray earned 50 total points
ID: 36714565
Try the below one as I think slightwv's typo mistake for c1 in place of c2:

Select c1 from table where c2='A'
Minus
Select c1 from table where c2 !='A';
Posted via EE Mobile
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 36716417
Thanks for the catch on the typo.
0
 

Author Closing Comment

by:jl66
ID: 36717557
The query is quite efficient. Thanks a lot for both.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

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.
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
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.
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.

679 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