Re: SQL Duplicates ?
From: Zbigniew Sliwa <zibi_at_at_yahoo.com>
Date: Thu, 23 Nov 2000 09:09:36 +0100
Message-ID: <3A1CD0C0.81E0F5B5_at_yahoo.com>
where b.telephone_number = a.telephone_number Good luck:)
Date: Thu, 23 Nov 2000 09:09:36 +0100
Message-ID: <3A1CD0C0.81E0F5B5_at_yahoo.com>
Robin,
1.If you use group by clause you can select only those columns which are after group by clause. Additionally you can use group functions such as sum, count ...
2.This will give you the thickets numbers: select a.telephone_number, a.ticket_count, b.ticket# from (select telephone_number, count(ticket#) ticket_count
from table group by telephone_number having count(ticket#) > 1) a, table b
where b.telephone_number = a.telephone_number Good luck:)
-- Regards, Zbigniew Sliwa Oracle Programmer Poland email: zibi_at_at_yahoo.com Robin Boscia wrote:Received on Thu Nov 23 2000 - 09:09:36 CET
>
> Eric,
> Thanks for your sql answer. This statement gives me the counts, but I
> also need to display the ticket # of all the duplicates in the output. If I
> select telephone_number, ticket, count(ticket#)
> it does not work. What am I doing wrong?
> Or better yet, what do I need to do right?
>
> Thanks
> Robin
>
> "Eric Givler" <egivler_at_flash.net> wrote in message
> news:D5fQ5.562$6W1.55314_at_news.flash.net...
> > select telephone_number, count(ticket#)
> > from table
> > group by telephone_number
> > having count(ticket#) > 1
> >
> > Boscia <rwboscia_at_worldnet.att.net> wrote in message
> > news:B634B0E6.890B%rwboscia_at_worldnet.att.net...
> > > I am a newbie when it comes to SQL, so I am not sure how to obtain the
> > > following.....
> > >
> > > I have a table that has customer telephone numbers in it and a table
that
> > > has ticket #'s in it.
> > > I want to do a query that shows all the ticket #'s that have referenced
> > > duplicate telephone numbers. This is how I want to output to appear....
> > >
> > >
> > > Telephone Number Ticket #
> > >
> > > 123-456-7890 1234
> > > 1235
> > > 1236
> > >
> > >
> > > Count 3 duplicates
> > > for TN 123-456-7890
> > >
> > >
> > > TN Ticket #
> > >
> > > 222-333-4568 2345
> > > 2346
> > > 9034
> > > 0932
> > >
> > > Count 4 duplicates
> > > for TN 222-333-4568
> > >
> > >
> > >
> > >
> > > I am sure this is probably very simple to do, but I do not have a
clue.....
> > > Thank you...
> > >
> > > Robin
> > >
> > >
> > >
> > >
> >
> >