Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duplicates

Status
Not open for further replies.

rboscia

IS-IT--Management
Dec 14, 2000
10
US
I am a newbie and I see several posts for dups but none that seem to work for my tables.
I have a table that contains customer telephone numbers (the telephone number is in 2 separate fields)and also a customer ticket #. I want to retrieve all the duplicates of those telephone numbers by ticket #.
My output should look like this

Telephone # Ticket #
xxx-xxx-xxxx 1
8
10
Total # of Occurances ##

Telephone # Ticket #
xxx-xxx-xxxx 3
7
15
Total # of Occurances ##

I can get the dups if I use just one field in my select statement, but when I seem to select and count more than just one field, it doesn't give me any output. I sure could use some help. Thanks!



 
Try the following (albeit, performance may be slow):

SELECT ticket#, tel#
FROM table
WHERE tel# IN
(SELECT tel#
FROM table
GROUP BY tel#
HAVING count(*) > 1)
ORDER BY ticket#

If tel# in two fields, use tel#1 || tel#2 in place of all tel# fields above.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top