find all duplicates

Hello guys,.

I want to know how to find all duplicate of a set of data records, in my application a duplicate is a combination of two columns, I do not want to group them, I want to know all the records duplicates


example of

CREATE TABLE EMPLOYER
(
ID NUMBER (12).
SSN VARCHAR2 (BYTE 9),
WGE NUMBER (10,2).
ERR_flg VARCHAR2 (1 BYTE)
)

INSERT INTO EMPLOYER(ID,SSN,WGE) VALUES (1,222222222,2532)
INSERT INTO EMPLOYER(ID,SSN,WGE) VALUES (2,111111111,2352)
INSERT INTO EMPLOYER(ID,SSN,WGE) VALUES (3,555555555,232)
INSERT INTO EMPLOYER(ID,SSN,WGE) VALUES (4,555555555,232)

3RD AND 4TH RECORDS ARE DUPLICATED... I WANT TO SHOW THEM IN MY QUERY AND UPDATE THE ERR_FLG TO 1


Thank you

Hello

Here's a way to get the results of a query without grouping:

WITH     got_cnt        AS
(
     SELECT     id, ssn, wge
     ,     COUNT (*) OVER ( PARTITION BY  ssn
                              ,            wge
                      ) AS cnt
     FROM    employer
)
SELECT     id, ssn, wge
FROM     got_cnt
WHERE     cnt     > 1
;

Almost all of the functions of aggregation (such as COUNT) have analytical equivalents, which can produce the same results without collapsing the data in one row per group.
The PARTITION BY an analytical function of clause is the clause GROUP BY of an aggregate query.

However, the update, what is wrong with grouping?
You can use something like the query above as a subquery in an UPDATE statement, but you will get the same results more simply with GROUP BY:

UPDATE  employer
SET     err_flg     = '1'
WHERE     (ssn, wge)     IN (
                    SELECT    ssn, wge
                    FROM      employer
                         GROUP BY  ssn, wge
                         HAVING    COUNT (*)     > 1
                           )
;

Published by: Frank Kulash, 24 May 2010 15:00
Additional UPDATE... GROUP BY example

Tags: Database

Similar Questions

  • Find a duplicate query MySQL syntax

    There is a request to "find duplicates" in SQL which is very useful, but I'm not sure what the syntax is for MySQL. It probably has something to do with a distinct group, chosen by but I'm not used to the use of these.

    It is he who finds all duplicates [FullName]

    SELECT CONTACTS.*
    WHERE (((CONTACTS. (FULLNAME) In (SELECT [FULLNAME] [CONTACTS] As Tmp GROUP BY [FULLNAME])
    After HAVING Count (*) > 1)))
    ORDER OF CONTACTS. FULLNAME, CONTACTS.COMPANY

    Anyone know?

    RichardODreamweaver wrote:
    > There is a request to "find duplicates" in SQL which is very useful, but I don't know
    > What's the syntax for MySQL.

    SELECT COUNT (*) AS, FULLNAME, COMPANY reps
    CONTACTS
    GROUP BY FULLNAME, COMPANY
    HAVE > 1 repetitions

    It is not something that I have used myself, but I got from MySQL Cookbook
    by Paul DuBois, published by O'Reilly. I have the first edition, which
    covers MySQL 4.0. I think that the second edition covers MySQL 5.0.

    If you use MySQL on a regular basis, you or your employer must
    Buy immediately. It will be to solve most of your problems and repay its
    cost several times.

    --
    Adobe Community Expert David Powers
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • How can I run a free scan for pc to check all duplicates multuple files and text files

    How can I run a free scan for pc to check all duplicates multuple files and text files

    You can try Easy Duplicate File Finder

  • How can I find several duplicate files and remove the using Windows Explorer

    Somehow I see several duplicate on my computer files.  I can tell when they arrived as all the duplicate files ' _10-Mar-15_1. ' " However, I don't know how they arrived.  I think that Google Drive was the culprit, but I can't be sure.

    How we (me) use Windows Explorer to find all files with "_10-Mar-15_1." and delete them all?

    I am using Windows 7 64 bit

    Thank you!!!

    Windows Explorer can do no such thing. To remove recursively a certain file is easy - see below. To identify duplicates and remove some of them is much more difficult, because:

    • Are two files duplicates because
      -They have the same name?
      -They are the same size?
      -They have the same file date?
      -They have the same content?
      -Everything above?
    • When they are, which ones should be deleted?
      -The oldest?
      -The most recent?
      -The batch?

    Here's how to remove a certain file to recursively. Assume that they are in the folder "C:\Users\BHunter\Documents".

    1. Click the start planet.
    2. Type cmd. exe and press ENTER.
    3. Enter the following command and press ENTER:
      dir/s/b/p 'C:\Users\BHunter\Documents\_10-Mar-15_1 '.
      This will show you all the files whose name above.
    4. del /s /q "C:\Users\BHunter\Documents\_10-Mar-15_1."
      This will permanently delete all files with the name above. You cannot restore them.
  • Photo library on mac was emissions additional no duplicated and then imported into Lightroom 6 PROBLEM: all duplicates appear (capitan OSX). Help me with this please!

    I imported all my photos in photo library on macbook OSX capitan. The photos were additional emissions not duplicated using power foto and gemini. This in the photo library. After checking, I have 48,000 photos, 80,000 duplicted >. After that completely eliminate the unwanted duplicate photos I import to LR6 by drag and drop the trump card in the library. Then all photos, including the deleted ones appear.

    Any solution or another way to import? photo for mac contains all my data being sought.

    This file did you import into Lr?

    And I would say you will find the duplicate in Lr, note the file name and then search the photo library to see if you have multiple instances of this photo. You cannot use Spotlight; you will need to use another utility like find easy.

    But you are right; If you have deleted them permanently from the "recently deleted" album they should be in the trash; you could confirm that as well.

    And use 'Show in Finder' alleged images duplicated in Lr to see where the copy is stored; that should also give you an idea of why it did not work.

  • find suspected duplicates after importation

    I have about 11 000 photos to organize.  I created a catalog name and chose to ignore suspected duplicates.  About 8 000 photos have been imported.  This is reasonable since I consolidated the photos from backups of two computers and current readers.

    How to find suspected duplicates?  I want to check duplicates and remove all duplicates for free disk space.  How to make the photos were not imported?

    Thank you, in advance, for any assistance.

    Ken

    Hi Ken!

    Lightroom does a pretty decent job find duplicates during the import, but is not as easily that once the images are in the catalog. Take a look at http://www.lightroom-plugins.com/DupesIndex.php. You can try it for free and see if it will help you.

  • How can I find all the plugins in the firefox browser

    HI I was wondering if I could ask a question how can I find all the installed plugins in the firefox lasted I would like to be able to know if, for example, if the shockwave plugin is updated and which version is currently installed in the firefox browser lasted.

    Thank you

    Hello Funny78, type Subject: addons in the address bar and then select plugins, add-ons manager opens and you can see the last version of the plugins (and other info), now click on the click to see if your plugins are up to date and see if it is.

    Thank you

  • How to find all my itunes backups that I did?

    How to find all my itunes backups that I did? I'm trying to restore my backup of June 2016 for a replacement phone, that I just got ATT,

    iTunes said my last backup was March 2016?

    iTunes > Preferences > devices.

    All local backups, with their dates are listed.

  • How to find all the previous adata firefox?

    I made an account of firefox. Then I uninstalled firefox and install a new one. Now, how can I find all my previous data from firefox.

    If you have enabled Firefox Sync, check out How can I add a device to Firefox Sync?

  • Where can I find all the drivers Win 7 for Satellite L40 - 14F

    Hi all
    Find all the drivers for L40 laptop model 14F for windows 7 OS? Is that someone has installed this OS? Is it possible to have some problems during installation? Thank you very much.

    Most of the new models is Win8 or Win10 models, they won't get Win7 drivers available.

  • Satellite Pro L40 PSL43E I need to find all the drivers XP

    I need to find all the XP drivers for this laptop in particular. Any ideas where I can find them. on this site, I get only the ' how downgrade "Pease help ASAP.

    If these drivers are available, you will be able to find these drivers on the European driver Toshiba page.

    If the drivers are not available on the European driver Toshiba page, the pilots were not released.

    But I have a suspicion; I found some XP for Sat L40 series drivers. Some series supports the same devices and so the drivers should work also.
    Check some unique XP from different L40 series drivers and maybe he would go.

    Ciao

  • Where can I find all the drivers for Tecra 8200

    Where can I find all the drivers for a Toshiba tecra 8200 PIII750/20/14 t/D/LM/W - I searched for drivers (all drivers) this Labtop can enyone please help me :)

    Got Windows XP:

    Post edited by: Rullings

    Hello

    Have you checked the European driver Toshiba page?
    This site contains all the necessary drivers for Win95, Win98, Win98SE, Win XP, ME, W2k.

    Only Vista drivers are not available for this oldie

    Check it!

  • My iPad and iPhone will be printed using AirPrint on my printer HP Deskjet 2540 for about 40 minutes and then will not be able to find all of the available air printers. No idea why.  The deskjet printer shows that there is a wireless connection.

    My iPad and iPhone will be printed using AirPrint on my printer HP Deskjet 2540 for about 40 minutes and then will not be able to find all of the available air printers. No idea why.  The deskjet printer shows that there is a wireless connection.

    Hi Mpsfeldt,

    Thank you for using communities Support from Apple!

    Your question, it looks like you are only able to use AirPrint sporadically. We know that situations of this kind can be frustrating, but we are here to help.

    To begin the process of solving problems, I suggest you to read about the section If you can not print on your printer AirPrint in the following article.

    On AirPrint - Apple Support

    Best!

  • Equium - cannot find all networks to connect

    Not very computer savvy so will try to explain the problem as best I can.

    I can connect to my internet connection via ethernet cable, but cannot connect wireless (although I have before).

    The wireless function is enabled and the orange light comes on. When I open connectivity doctor and go on the radar screen, my internet connection appears (along with a few others)
    When I hover over the connection icon at the bottom of the screen, it says that "wireless connections are available", but when I click it it establishes that "windows cannot find any network" then understand that there must be an easy way to solve this problem, it can not find all networks to log, mine or one of my neighbors!

    Hi paulymart,

    Which model of laptop, you have exactly and that you've updated the driver WLAN?

  • HP 15-p238tx: How can I find all my drivers.

    I install windows 7 on my 15-p238tx. I'd like to find all my drivers.

    Hello:

    You should be able to use all the W7 x 64 drivers and software (do not use the BIOS and firmware files) on your model.

    http://h22207.www2.HP.com/us-en/drivers/selfservice/HP-Pavilion-15-P000-notebook-PC-series/6936226/model/7174371

    To install the graphics on your model, you must:

    1. install the Intel chipset installation and restart utility.

    2. install the Intel HD graphics driver and restart.

    3. install nVidia HD graphic driver and restart.

Maybe you are looking for

  • No spell check on Shaw Webmail via firefox

    I had spell check on Shaw Webmail emails until last week when he disappeard suddenly.I contacted Shaw and they told me to contact you, such as the browser that I use to access the internet.Thank youGary

  • Bug WiFi

    anyone else have problems with wifi with the Bionic? I searched and see people have problems connecting to different access points, but I have a different problem. When I turn on the wifi radio, it takes forever to enter the access point that I'm clo

  • Reserved DHCP WRT160NL customers are not appearing in the window of DHCP reservation... Why?

    I have 5 computers connected to my router. 4 are wired and I put in place so that each of the 5 has its own static address. One of these computers is my DVR security camera system to allow monitoring my cameras remotely. It worked very well for years

  • Set the default printer

    I try to add the X 7170 Lexmark all in a printer as your default on my laptop, but it is not listed as one of the printers.  I need to know if it is or is not compatible with this computer and, if yes, now I do.  (We have a network of 2 computers - t

  • I have a Dell computer with a Vista operating system. My dell dock will charge is no longer. Help?

    I have a Dell computer with a Vista operating system. My dell dock will charge is no longer. Help?