Help looking for repeated records and delete them

I have a table like this

With a (too)
Select '1234' ID, 'AAA' Code of all the double union
Select '9999', 'AAA' from dual union all
Select '8888', 'CCC' from dual union all
Select '7777', 'AAA' from dual union all
Select '6666', 'CCC' from dual union all
Select '1234', 'BBB' of the double
)

1. I want a list of all (double/same) ID's, which has both "AAA" and "BBB" codes
2. I want to delete duplicates/same ID's where Code = 'BBB '.

Constraints
(ID + Code = primary key)
I do not know the ID's before hand, IE I can not pass it.
A huge table

SeshuGiri wrote:
1. I want to list all (double/same) ID's which codes the two "AAA" and "BBB".

The following SQL statement will list the duplicates:

SQL> SELECT  ID
  2  FROM    TEST    T2
  3  WHERE   CODE IN ('AAA','BBB')
  4  GROUP BY ID
  5  HAVING COUNT(*) > 1
  6  /

ID
----
1234

2. I want to delete duplicates/same ID's where Code = 'BBB '.

SQL> DELETE FROM TEST T1
  2  WHERE   CODE='BBB'
  3  AND     EXISTS
  4          (
  5                  SELECT  ID
  6                  FROM    TEST    T2
  7                  WHERE   T1.ID = T2.ID
  8                  AND     CODE IN ('AAA','BBB')
  9                  GROUP BY ID
 10                  HAVING COUNT(*) > 1
 11          )
 12  /

1 row deleted.

SQL> SELECT * FROM TEST;

ID   COD
---- ---
1234 AAA
9999 AAA
8888 CCC
7777 AAA
6666 CCC

HTH!

Published by: Centinul on December 18, 2009 13:17

Tags: Database

Similar Questions

  • How to use vbscript to find all corrupt them office files and delete them

    I have to browse a fileshare and locates all corrupted files (especially for office files) a sloppy migratory balance and remove them.  I've been running this process in a list provided by the seller, but this will be the 3rd time through.  I want to identify corrupted files and delete them.

    I will search through a windows 2008 Server fileshare.
    Any help would be appreciated.

    Hello

    The question you have posted is better suited for the MSDN forums. Please post your questions in the MSDN forums for assistance.

    Here is the link: http://social.msdn.microsoft.com/forums/en-US/categories/

  • How to make the new messages show up on Windows mail? columns for messages sent and deleted without long appears. How to make a comeback?

    Original title: Messages a suddenly begin to appear new downstairs; How can I make them appear at the top?  In addition, the columns for messages sent and deleted no long appears.  How to make a comeback?

    It's the Windows Mail 06 comes with Vista.

    Hello

    Step 1:

    Follow these steps and check if that helps.

    (a) open Windows Mail.

    (b) click on view

    (c) select sort by , click on to.

    Do you view recent messages on top.

    Step 2:

    (a) in Windows Mail.

    (b) click on view

    (c) select Layout.

    (d) under the basic click toolbar. (To display the toolbar if it disappears).

    (e) click on customize the toolbar and add Send/recv current toolbar features.

    See also:

    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-problems-with-Windows-Mail

    Hope this helps,

  • How can I go on my computer for my programs and run them one by one (individually)?

    Hi, how can I go on my computer for my programs and run them one by one (individually)?

    Original title: programs

    Sorry, I'm not sure I'm 100%. Could you clarify it please.

    for example, what programs you want to run?

    Most of the programs of supply to create an icon on your desktop when they are installed, in which case a click that. If this is not the case, the other place to look is the menu of your . Click on the round, and you should find most (if not all) your programs in there.

    Programs are also usually stored in C:\program files or C:\program files (X 86). If you access this directory/folder, you should be able to find the program there as well and click sound. EXE file. that is for works2007 - C:\program files\microsoft works\WksWP.exe

    To close a program sound usually in a menu, or the [x] icon red on the right top of the window.

  • I'm looking for (without wire and ati) drivers sony vaio model pcg - 61611 L 27524236 3006912 .SN

    I'm looking for (without wire and ati) drivers sony vaio model pcg - 61611 L 27524236 3006912 .SN

    Hello Jazymich,

    Thanks for the post.

    PCG - 61611L is the configuration of the equipment donated by Sony code.

    Try to exactly locate the model #:

    http://eSupport.Sony.com/us/p/support-info.pl?info_id=264#notebook

    Enter model # in the following link for available drivers:

    http://eSupport.Sony.com/us/p/select-System.pl?Director=driver

    If my post answered your question, please mark it as an "accepted Solution".

  • Expert Consultant DPS to look at our record and make it work

    How to find a consultant/expert DPS?  We spent hours on the presentation, but we can't operate the Viewer.  We posted my question on this blog, but nobody seems to know how to solve our problem.  I hope that there is someone who can look at our record and make some suggestions on how we can make it work.

    Send me a private message.

    Bob

  • Looking for PDF files and help online

    Hello

    I have create a RoboHelp 8 online help system, which also contains a PDF of some user Guides. Ideally I'd like the user to be able to search for information in the HTML pages and PDFs (written and compiled using FrameMaker 9). Is there a way that it is possible?

    Thank you

    On 'Hat' and 'that' - disable the substring search.

    See www.grainge.org for creating tips and RoboHelp

    @petergrainge

  • Can not switch to OSX Recovery Mode: looking for the keyboard and magic mouse

    I'm trying to reset my end 2012 Mac Mini 2.3GHz/i7/16GB to factory settings to try to get the machine a new lease on life.

    However, when I try to enter in Recovery Mode (in now command ⌘ + R when the system starts up), the machine will stop to a screen showing the instructions to turn on a magical keyboard and Magic Mouse.

    I have a trendy apple (USB) keyboard and a USB mouse is connected.

    How can I activate these entries, or how can I pass this screen looking for a keyboard/Magic Magic Mouse?

    [I guess one option is to use a magic mouse or a magical keyboard - I have in my office - but it is not sensible that you need them to access recovery mode].

    Thank you

    Got my Magic Mouse of the office, got into recovery mode. Surprised, you need a Magic Mouse, and who does not have a USB mouse to the recovery mode!

  • Email that can be removed and freezes the computer when you try or when you scan up to this particular email when opening other emails. Other emails are very good and can open and delete them.

    I have an email on Outlook Express, which leaves me the delete (distribution of the mail... Mail delivery failed).  Whenever I try to delete or scan down to it, it causes my computer to freeze and have to go out and come back and work with my emails.  All other emails can be read and deleted.  How can I remove this email? I have Windows XP and uses a Compacq computer.  There is also a small icon of trombone to the left of this message.  Thanks for any help you can give me.

    Try to go to view | Layout and turn off the preview pane, so that the message does not open when you select.  Select the message and press and hold the SHIFT key and press the Remove button to remove it permanently.  See if it works.

    Steve

  • Offline Photoshop CHC help looking for a malfunction.

    Search help Photoshop is not back all the results offline. Please read this thread:

    http://forums.Adobe.com/message/3213191

    Local aid has been downloaded for all Adobe Creativity Suite applications and shows that "Current".

    Under the left hand pane search 'Local' drop-down box is selected.

    Results of the filter is correctly selected "using Adobe Photoshop CS5".

    Looking for something like "brush" returns NOTHING in offline mode. (online mode works well).

    The help document "with the help of Adobe Photoshop CS5" is vissible in offline mode (in the right pane) but simply do not return no results when searched.

    All other documents help offline (for the rest of the Suite of creativity) seems to work OK.

    This issue should now be resolved via the update instructions posted here: http://forums.adobe.com/message/3216601#3216601

  • you are looking for an mp3 and acc music player application

    Hi all

    I'm looking for a music player that I can load into my craft mp3 songs and VAC and power play in offline mode in iPhone. I already use Apple music app but am looking for something else too.

    Any recommendations?

    the application of Aboriginal music do this thing.

    Just put the music in iTunes and sync with your iPhone.

  • Looking for a driver and Power Meter solution.

    Hello

    I'm looking for a better time LabView real solution available for reading (or analysis) and storage of voltage, current, power, or PF too since a 110 V AC direct online. Any combination of pilot and profitable meter plug-and-play is available?

    Thanks for your time!


  • Something is blocking some games and I get an embarrassing box and it says windows is looking for a solution and I have never one, I can not also close the programs it goes well.

    Also told me that I have to install a new version of silverlight, what I've done three times and he always tells me to install a new version of silverlight, I clicked also paper painted Steves and blinds to watch something my sister wanted to, I think that is where my problem started because I never had ads for this before and now the games I can't play on pogo have an announcement of Steves blinds and wallpaper and when it counts up to game it stops in 18 seconds or goes to zero hour, but never loads.  Please help me.

    Hello

    Which browser is installed on the computer?

    Perform the steps from the link mentioned below if you have Internet Explorer installed on the computer.

    The problems of games online using Internet Explorer

    Hope this information helps.

  • Windows 7 is constantly looking for other networks and drop connection

    Original title: the upgrade of Windows 7 for XP

    I first installed this OS a year ago to this date. Loved, absolutley was entrenched with how easy it was and just how 'worked '. I am a software developer myself and am happy to report all my IDEs, the server settings, etc. all worked like a charm. I had a little problem with VPN but it works with the Vista one (with some work) so I can't complain.

    My problem and this is why I uninstalled windows 7 and will be EVER is back at it before it is solved the same problem 10 years ago. He keeps every 60 seconds looking for other networks or drop the connection no reason apparent. With windows XP, I could disable the Zero wireless and everything would be fine. However, with windows 7 if I turn the WLAN service nothing on this earth that will allow me to connect to it without a third-party application.

    In the end I used a 3rd party app made by the chipset driver and it still failed (but had limited success).

    It is a known problem with windows operating systems. This just "does not work" at all. It's a pain in the thigh and is the reason why people are saying that the wireless is terrible for gaming. I know that isn't true since I have never had a fall with windows XP or my dual boot SuSe OS. 3rd parties even tried to fix this for microsoft in creating the WLAN and Vista Antilag optimizer which all fail for windows 7.

    And just to show you how apparent is this bug...

    customer complaints

    It seems to somehow keep seeps through the cracks with every version of windows. Simply because I know that this wont never be resolved after 10 years ive thrown my copy in the trash and advising all my loved ones to stay on XP. I used to think... "they'll fix" but quite honestly, I think that microsoft is tone deaf to it.

    With regard to upgrading my firmware on my router is concerned, I have programmed my own. I used 3 different routers. My drivers are all up to this date for my card wireless on this box. I used XP drivers with slightly better results but remains unacceptable. I was running with a hackintosh and vmware fusion rather than deal with these headaches after work.

    Maybe im being a bit too critical, but make you pay back for a BONE which does not have everything because of XP.

    After buying a WNDR3700 N600 top double band brand new brand of the router Netgear power line she didn't always.

    2 solid ways fixed my issue.

    the network of windows 7 reason fails

    One, I had to turn off the service navigation computer in administrative services as noted above.

    Two, I had to turn off the power save feature on the usb network adapters.

    Not many people understand how to solve this problem, but I would ditch the derivative of the net bios completely.

  • Search for formatting text and convert them to the outline

    Hello! I need a script that finds the text formatting and convert them to the outline. If one who can do this script please provide.

    Thank you

    I need the script to only specific formatting for once. So I don't need any fancy or dialog boxes option. I also did the character for the formatting style.

    Try this.

    var doc = app.activeDocument;
    app.findTextPreferences = null;
    app.findTextPreferences.appliedCharacterStyle = "charstylename";
    var found = doc.findText();
    for(var i =0;i
    

    Kind regards

    Cognet

Maybe you are looking for

  • Faulty memory to Equium A60

    Hi all Has just been given a notebook Equium A60 to look at, basically when I try recovery DVD, all is well until the phone restarts, errors occur with files system etc, blue screen of death, I tried MEMTEST86 memory and he finished only 12% before i

  • Satellite A60: Question about upgrade from the CD - RW drive

    I have a laptop A60 sitting with a CD-ROM/DVD-ROM drive. I want to upgrade to a CD-RW/DVD-ROM drive. I understand that I have the choice between UJDA 750 and the SD-R2512. Someone can offer a preference and I need firmware / drivers for these to work

  • Try to restore WIndows XP - make a LOT of mistakes... Failed to load these 13 updates. You may receive 0 x 80246008 error.

    Here's the latest list of errors for the updates.  Any suggestions?  Grateful if you can help. Receive this error code: Error Code: 0 x 80246008 Update for Windows XP (KB961118)Update for .NET Framework 3.5 Service Pack 1 for the .NET Framework Assis

  • Run & copy a DVD

    I have a DVD drive that has been copied to another computer using Windows VISTA. When Itry to run it on my computer using Windows X P IT won't be even open? How can I open this DVD? & How can I copy using X P?

  • WIFI antennas

    I want to push my WIFI connection. I use a computer laptop dell vostro. What should I buy? antennas? card? Ty