If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > basic PL/SQL question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-16-04, 11:14
dude78 dude78 is offline
Registered User
 
Join Date: Jan 2004
Posts: 5
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!

J
Reply With Quote
  #2 (permalink)  
Old 01-16-04, 11:19
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: basic PL/SQL question

Not PL/SQL, just SQL:

select id, program, count(*)
from x
group by id, program
having count(*) > 1;
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On