Improve company productivity with a Business Account.Sign Up

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

count problem in oracle SQL

I have table a and table b with column x in both tables.

In table b the column x  can have the same value on several rows while in table a column x only have unique values.

I want to count the number of rows in table a where the same value exists on more than 10000 rows in table b!
0
bear_2013
Asked:
bear_2013
  • 2
  • 2
1 Solution
 
awking00Commented:
select x, count(*)
from tableb b
where exists
(select 1 from tablea a
 where a.x = b.x)
group by x
having count(*) > 10000;
0
 
sdstuberCommented:
select count(*) from A
where X in (select X from B group by X having count(*) > 10000)
0
 
sdstuberCommented:
awking00,  I think you have the tables backwards.  Other than that, the exists method should also work


bear_2013 - both of our methods assume X is NOT NULL.  Is that a safe assumption?
0
 
awking00Commented:
I seem to have been thinking backwards a lot lately :-)
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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