Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

count problem in oracle SQL

Posted on 2013-11-05
4
Medium Priority
?
452 Views
Last Modified: 2013-11-18
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
Comment
Question by:bear_2013
[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
  • 2
4 Comments
 
LVL 32

Expert Comment

by:awking00
ID: 39624774
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
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 39624788
select count(*) from A
where X in (select X from B group by X having count(*) > 10000)
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 39624803
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
 
LVL 32

Expert Comment

by:awking00
ID: 39624833
I seem to have been thinking backwards a lot lately :-)
0

Featured Post

Technology Partners: 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

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

688 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