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 

Select Duplicate Records

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


Joined: 17 Dec 2002
Posts: 22
Topics: 10

PostPosted: Fri Jan 21, 2005 10:52 pm    Post subject: Select Duplicate Records Reply with quote

I would like to select duplicate records in the following way:

[code:1:8df65d5f99]
TBL_A:
FIRST_NAME
Back to top
View user's profile Send private message
programmer1
Beginner


Joined: 18 Feb 2004
Posts: 138
Topics: 14

PostPosted: Mon Jan 24, 2005 7:28 am    Post subject: Reply with quote

WallaceC,

Try this,

select a.first_name, a.last_name, a.city, a.state, b.city, b.state
from tbl_a a, tbl_a b
where a.first_name = b.first_name and
a.last_name = b.last_name
_________________
Regards,
Programmer
Back to top
View user's profile Send private message
programmer1
Beginner


Joined: 18 Feb 2004
Posts: 138
Topics: 14

PostPosted: Mon Jan 24, 2005 7:42 am    Post subject: Reply with quote

This SQL won't give you the desired results.

Sorry about this.
_________________
Regards,
Programmer
Back to top
View user's profile Send private message
viji
Beginner


Joined: 03 Dec 2002
Posts: 17
Topics: 11

PostPosted: Thu Jan 27, 2005 4:58 am    Post subject: Reply with quote

WallaceC, Try the following SQL....
Code:

Select
A.FIRST_NAME,
A.LAST_NAME,
A.CITY,
A.STATE,
B.CITY,
B.STATE
from
(SELECT * FROM TBL_A D WHERE EXISTS (SELECT FIRST_NAME,LAST_NAME,MAX(TITLE) FROM  TBL_A E WHERE D.FIRST_NAME=E.FIRST_NAME AND A.LAST_NAME=E.LAST_NAME
GROUP BY FIRST_NAME,LAST_NAME
HAVING MAX(TITLE)=D.TITLE )
) AS A
,
TBL_B
WHERE
A.FIRST_NAME=B.FIRST_NAME
AND A.LAST_NAME=B.LAST_NAME
AND A.TITLE^=B.TITLE
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