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 > Database Server Software > DB2 > How To Return Rows with Duplicate Values?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-07-11, 17:07
dvdaddict32 dvdaddict32 is offline
Registered User
 
Join Date: Mar 2010
Posts: 32
How To Return Rows with Duplicate Values?

I am fairly new to DB2, and can't figure out how to return a result set that shows me people with duplicate values in certain fields.

For example, my table has two differnet SSN fields


recip_ssn mbr_ssn


11223344 234558899
11223344 234558899


I want to see people who have two mbr_ssns in the table that are the same value. If I try count(mbr_ssn) > 1, it may return people with different mbr_ssn numbers.


Can anyone help?
Reply With Quote
  #2 (permalink)  
Old 01-07-11, 17:58
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
i'm not sure i understand your question
Code:
SELECT recip_ssn 
     , mbr_ssn
  FROM daTable
GROUP
    BY recip_ssn 
     , mbr_ssn
HAVING COUNT(*) > 1
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
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