Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL for getting duplicate records?
On Thu, 12 Aug 1999 15:17:26 -0700, "Rich Gilmour" <richg_at_aaepa.com>
wrote:
>
>Hi all.
>
>Forgive me if this sounds really stupid, but I'm new to SQL. Could somebody
>please explain how to properly contsruct a SQL statement that returns all
>records in a table with matching field values? I've managed to pull distinct
>values, but thats not what I'm after.
>
>Thanks in advance,
You might try this:
SELECT CheckDup.keyValue , CheckDup.viewingValue1 , CheckDup.viewingValue2 , CheckDup.viewingValueNthNumber
FROM duptable As Tmp GROUP BY Tmp.keyValue HAVING Count(*)>1 )))ORDER BY CheckDup.keyValue;
Where keyValue is the value(s) you want to check for duplicates, and viewingValue# is one or more additional values you want to view as well.
I pulled this code from a MS-Access check duplicate value query and modified it for Oracle usage as best I can. It should work with some modifications to get your values.
Good luck,
Boyce G. Williams, Jr.
Received on Mon Aug 16 1999 - 11:06:47 CDT