Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: SQL help

RE: SQL help

From: Pardee, Roy E <roy.e.pardee_at_lmco.com>
Date: Mon, 29 Apr 2002 14:46:30 -0800
Message-ID: <F001.004529AC.20020429144630@fatcity.com>


This should get you a list of the combos of ID, Company & Country that are repeated in the table:

<warning--air SQL!>
SELECT ID, Company, Country, COUNT(*) NumRecs FROM my_table
GROUP BY ID, Company, Country
HAVING COUNT(*) > 1
</warning--air SQL!>

Or if you need all the records that belong to repeated combos of ID, Company & Country, you could say something like:

<warning--air SQL!>
SELECT t.*
FROM my_table t, (SELECT ID, Company, Country, COUNT(*) NumRecs

                  FROM my_table
                  GROUP BY ID, Company, Country
                  HAVING COUNT(*) > 1) sq
WHERE t.ID      = sq.ID      AND
      t.Company = sq.Company AND
      t.Country = sq.Country

</warning--air SQL!>

Maybe that would suit?

HTH,
-Roy

Roy Pardee
Programmer/Analyst
SWFPAC Lockheed Martin IT
Extension 8487

-----Original Message-----

Sent: Monday, April 29, 2002 3:12 PM
To: Multiple recipients of list ORACLE-L

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



MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: k k
  INET: new_oracle_user_at_hotmail.com

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: ListGuru_at_fatcity.com (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).
--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Pardee, Roy E
  INET: roy.e.pardee_at_lmco.com
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: ListGuru_at_fatcity.com (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). Received on Mon Apr 29 2002 - 17:46:30 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US