Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

count problem in oracle SQL

Posted on 2013-11-05
4
Medium Priority
?
453 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 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
Suggested Courses

916 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