Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

Request a high efficient query

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
jl66
Asked:
jl66
  • 2
2 Solutions
 
slightwv (䄆 Netminder) Commented:
Try this:

Select c1 from table where c1='A'
Minus
Select c1 from table where c2 !='A';
0
 
Swadhin RaySenior Technical Engineer Commented:
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
 
slightwv (䄆 Netminder) Commented:
Thanks for the catch on the typo.
0
 
jl66Author Commented:
The query is quite efficient. Thanks a lot for both.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now