k k wrote:
>
> Hello all,
>
> I need some SQL help .. I have a table with containing duplicate records but
> because they have differents status they really are duplicate .. i need to
> find these .. here is an example of what the table contains :
>
> ID Company Country Status
> 5521 ABC US 1
> 5521 ABC US -1
> 8877 DEF UK 0
> 8877 DEF UK 1
>
> I want to pull the records where all the columns are the same except for the
> status column .
>
> Any help is greatly apprecieted
>
> K
>
You have several solutions.
GROUP BY ID, COMPANY, COUNTRY
HAVING COUNT(STATUS) > 1
is one.
WHERE EXISTS (SELECT NULL
....
WHERE A.ID = B.ID
AND A.COMPANY = B.COMPANY
AND A.COUNTRY = B.COUNTRY
AND A.STATUS > B.STATUS)
is another.
I am sure you can also do something with MINUS or INTERSECT
...
--
Regards,
Stephane Faroult
Oriole Software
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Stephane Faroult
INET: [EMAIL PROTECTED]
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
San Diego, California -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).