Tuesday, March 27, 2012

basic PL/SQL question

Okay,

kinda new at this:

I have Id's that can have duplicates. I also have programs that can have duplicates. I am looking for a list of IDs with programs that have a rowcount > 1 for that given id.

Example

ID Program
-- ----
111 12345 <----These are the records I want
111 12345 <----
222 32145
333 99999
444 55555
444 66666

with my current query I keep getting 1 ID per 1 Program?

What PL/SQL do I need?

Thanks in advance!

JNot PL/SQL, just SQL:

select id, program, count(*)
from x
group by id, program
having count(*) > 1;

No comments:

Post a Comment