Solved

count problem in oracle SQL

Posted on 2013-11-05
4
441 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
  • 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 73

Accepted Solution

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
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…
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 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

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now