?
Solved

Request a high efficient query

Posted on 2011-09-27
4
Medium Priority
?
209 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
[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
4 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 1800 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 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Suggested Courses

770 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