MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

duplicate value in column ?

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
tcurrier
Intermediate


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Sat Apr 25, 2009 1:31 pm    Post subject: duplicate value in column ? Reply with quote

Our database has a column called 'policy_number' and a column
called 'veh_identification_number'....

We found out recently that a there are a lot of 'policy_number's that have duplicate 'veh_identication_number's (vehicle was mistakenly added to a policy twice)

Is there a way to identify all of the 'policies' for which this situation exists ?

policy_number veh_identifcation_number
1111111111 1FASP15J2TW127478 (duplicate)
1111111111 JT2AL32W8F0153774
1111111111 1FASP15J2TW127478 (duplicate)

2222222222 2GTEK19R0V1516247 (duplicate)
2222222222 2GTEK19R0V1516247 (duplicate)
2222222222 1N6HD16Y4KC341829
2222222222 A61J4FJ78L4KL562574

Thanks for any help.....
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sat Apr 25, 2009 2:07 pm    Post subject: Reply with quote

tcurrier,

Untested sql

Code:

SELECT POLICY_NUMBER
      ,VEH_ID_NUMBER
  FROM table
 GROUP BY POLICY_NUMBER
         ,VEH_ID_NUMBER
HAVING COUNT(*) > 1 


Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
tcurrier
Intermediate


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Sat Apr 25, 2009 4:48 pm    Post subject: Reply with quote

Thanks, Kolusu

Works great ....
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group