Macro to remove duplicate rows between two worksheets

Hi
We have a master file which multiple users access through 'sharepoint'.
The 'sharepoint' service had an issue, and this master file (which two users spend a day each working on) has not updated.
We are left with two variations of the same master file, and need to merge them together - allowing adjustments made by both users to stand. The master has 45 columns, and the copies have between 20916 and 21034 rows inc header.
As I have basic capabilities with Macro's, would someone be able to advise?
Kind regards
Metakio

Re:  Merging two files
One way...
In a new workbook, paste copies of the two sets of data onto a single sheet with one set of data directly below the other.
Use Excel's Remove Duplicates feature to remove the duplicate rows.
Jim Cone
Portland, Oregon USA
free & commercial excel programs
https://jumpshare.com/b/O5FC6LaBQ6U3UPXjOmX2

Similar Messages

  • First attempt to remove duplicate rows from a table...

    I have seen many people asking for a way to remove duplicate rows from data. I made up a fairly simple script. It adds a column to the table with the cell selected in it, and adds the concatenation of the data to the left into that new column. then it reads that into a list, and walks through that list to find any that are listed twice. Any that are it marks for DELETE.
    It then walks through to find each one marked for delete and removes them (you must go from bottom to top to do this, otherwise your row markings for delete don't match up to the original rows anymore). Last is to delete the column we added.
    tell application "Numbers"
    activate
    tell document 1
    -- DETERMINE THE CURRENT SHEET
    set currentsheetindex to 0
    repeat with i from 1 to the count of sheets
    tell sheet i
    set x to the count of (tables whose selection range is not missing value)
    end tell
    if x is not 0 then
    set the currentsheetindex to i
    exit repeat
    end if
    end repeat
    if the currentsheetindex is 0 then error "No sheet has a selected table."
    -- GET THE TABLE WITH CELLS
    tell sheet currentsheetindex
    set the current_table to the first table whose selection range is not missing value
    end tell
    end tell
    log current_table
    tell current_table
    set list1 to {}
    add column after column (count of columns)
    set z to (count of columns)
    repeat with j from 1 to (count of rows)
    set m to ""
    repeat with i from 1 to (z - 1)
    set m to m & value of (cell i of row j)
    end repeat
    set value of cell z of row j to m
    end repeat
    set MyRange to value of every cell of column z
    repeat with i from 1 to (count of items of MyRange)
    set n to item i of MyRange
    if n is in list1 then
    set end of list1 to "Delete"
    else
    set end of list1 to n
    end if
    end repeat
    repeat with i from (count of items of list1) to 1 by -1
    set n to item i of list1
    if n = "Delete" then remove row i
    end repeat
    remove column z
    end tell
    end tell
    Let me know how it works for y'all, it worked good on my machine, but I know localization is causing errors sometimes when I post things.
    Thanks,
    Jason
    Message was edited by: jaxjason

    Hi jason
    I hope that with the added comments it will be clear.
    Ask if something is always opaque.
    set {current_Range, current_table, current_Sheet, current_Doc} to my getSelection()
    tell application "Numbers09"
    tell document current_Doc to tell sheet current_Sheet to tell table current_table
    set list1 to {}
    add column after column (count of columns)
    set z to (count of columns)
    repeat with j from 1 to (count of rows)
    set m to ""
    tell row j
    repeat with i from 1 to (z - 1)
    set m to m & value of cell i
    end repeat
    set value of cell z to m
    end tell
    end repeat
    set theRange to value of every cell of column z
    repeat with i from (count of items of theRange) to 1 by -1
    (* As I scan the table backwards (starting from the bottom row),
    I may remove a row immediately when I discover that it is a duplicate *)
    set n to item i of theRange
    if n is in list1 then
    remove row i
    else
    set end of list1 to n
    end if
    end repeat
    remove column z
    end tell
    end tell
    --=====
    on getSelection()
    local _, theRange, theTable, theSheet, theDoc, errMsg, errNum
    tell application "Numbers09" to tell document 1
    set theSheet to ""
    repeat with i from 1 to the count of sheets
    tell sheet i
    set x to the count of tables
    if x > 0 then
    repeat with y from 1 to x
    (* Open a trap to catch the selection range.
    The structure of this item
    «class
    can't be coerced as text.
    So, when the instruction (selection range of table y) as text
    receive 'missing value' it behaves correctly and the lup continue.
    But, when it receive THE true selection range, it generates an error
    whose message is errMsg and number is errNum.
    We grab them just after the on error instruction *)
    try
    (selection range of table y) as text
    on error errMsg number errNum (*
    As we reached THE selection range, we are here.
    We grab the errMsg here. In French it looks like:
    "Impossible de transformer «class
    The handler cuts it in pieces using quots as delimiters.
    item 1 (_) "Impossible de transformer «class » "
    item 2 (theRange) "A2:M25"
    item 3 (_) " of «class NmTb» "
    item 4 (theTable) "Tableau 1"
    item 5 (_) " of «class NmSh» "
    item 6 (theSheet) "Feuille 1"
    item 7 (_) " of document "
    item 8 (theDoc) "Sans titre"
    item 9 ( I drop it ) " of application "
    item 10 ( I drop it ) "Numbers"
    item 11 (I drop it ) " en type string."
    I grab these items in the list
    {_, theRange, _, theTable, _, theSheet, _, theDoc}
    Yes, underscore is a valid name of variable.
    I often uses it when I want to drop something.
    An alternate way would be to code:
    set ll to my decoupe(errMsg, quote)
    set theRange to item 2 of ll
    set theTable to item 4 of ll
    set theSheet to item 8 of ll
    set theDoc to item 10 of ll
    it works exactly the same but it's not so elegant.
    set {_, theRange, _, theTable, _, theSheet, _, theDoc} to my decoupe(errMsg, quote)
    exit repeat (*
    as we grabbed the interesting datas, we exit the lup indexed by y.*)
    end try
    end repeat -- y
    if theSheet > "" then exit repeat (*
    If we are here after grabbing the datas, theSheet is not "" so we exit the lup indexed by i *)
    end if
    end tell -- sheet
    end repeat -- i
    (* We may arrive here with two kinds of results.
    if we grabbed a selection, theSheet is something like "Feuille 1"
    if we didn't grabbed a selection, theSheet is the "" defined on entry
    and we generate an error which is not trapped so it stops the program *)
    if theSheet = "" then error "No sheet has a selected table."
    end tell -- document
    (* Now, we send to the caller the interesting datas :
    theRange "A2:M25"
    theTable "Tableau 1"
    theSheet "Feuille 1"
    theDoc "Sans titre" *)
    return {theRange, theTable, theSheet, theDoc}
    end getSelection
    --=====
    on decoupe(t, d)
    local l
    set AppleScript's text item delimiters to d (*
    Cut the text t in pieces using d as delimiter *)
    set l to text items of t
    set AppleScript's text item delimiters to "" (*
    Resets the delimiters to the standard value. *)
    (* Send the list to the caller *)
    return l
    end decoupe
    --=====
    Have fun
    And if it's not clear enough, you may ask for more explanations.
    Yvan KOENIG (from FRANCE mardi 27 janvier 2009 21:49:19)

  • How can I remove all content between two tags using Find/Replace regular expressions?

    This one is driving me bonkers...  I'm relatively new to regular expressions, but I'm trying to get Dreamweaver to remove all content between two tags in an XML document.  For example, let's say I have the following XML:
    <custom>
    <![CDATA[<p>Some text</p>
    <p>Some more text</p>]]>
    </custom>
    I'd like to do a Find/Replace that produces:
    <custom>
    </custom>
    In essence, I'd like to strip all of the content between two tags.  Ideally, I'd like to know how to strip the CDATA content as well, to return the following:
    <custom>
    <![CDATA[]]>
    </custom>
    I'd much appreciate any suggestions on accomplishing this.
    Many thanks!

    Thanks much for your response.  I found David's article to be a little thin with respect to examples using quantifiers in coordination with the wildcard metacharacters; however, I was able to cobble together a working expression through trial and error using the information he presented.  For posterity, here’s the solution:
    Find:
    <custom>[\d\D]*?</custom>
    Replace:
    <custom>
    <![CDATA[]]>
    </custom>
    I believe this literally translates to:
    [] = find anything in this range/character class
    \d = find any digit character (i.e. any number)
    \D = find any non-digit character (i.e. anything except numbers)
    *? = match zero or more times, but as few times as possible (i.e. match multiple characters per instance, but only match one instance at a time, or none at all)
    I’m still not sure how to effectively utilize the . wildcard.  For example, the following expression will not find content that ends with a number:
    <custom>.*?[\D]*?</ custom >
    I'm presuming this is because numbers aren't included in the \D metacharacter; however, shouldn't numbers be picked up by the .*? expression?

  • Remove Duplicate Rows in Numbers 09

    Is there a way to remove duplicate rows in Numbers 09? For example I have 2 Tables and the values of Column A are mainly the same, but there are definitely a few dozen unique values in 1 table which are not in table 2 and visa versa. I'd like to make a new table with a column A with all of the values, but with duplicates removed so that I can then compare the values of a different column based on the value of Column A for each table.

    I copied tabeau 1 and tableau 2 in tableau 3 then in cell E2 of tableau 3 I entered the formula:
    =COUNTIF($A$1:$A1,"="&A)
    Using fillDown, I filled the column E
    I get 0 if the cell a is unique
    I get 1 (or higher) if the cell is available several times.
    Sort upon column E
    delete the rows whose cell E is not 0.
    Yvan KOENIG (VALLAURIS, France.) samedi 22 août 2009 11:08:15

  • Removing duplicate rows from SELECT

    Hi, I was wondering if there was any way to remove duplicate rows from a select statement.
    My table looks like this:
    CREATE TABLE CUS_ID_TO_PC_ID (
    CUSTOMER_ID VARCHAR2 (10) NOT NULL,
    PC_ID VARCHAR2 (25) NOT NULL,
    PASSWORD VARCHAR2 (25) NOT NULL,
    REG_DATE DATE,
    PRODUCT_DESC VARCHAR2 (25),
    EXPIRE_DATE DATE,
    SERIAL_NBR VARCHAR2 (12),
    LDAP_USER VARCHAR2 (200),
    COMMENTS VARCHAR2 (2000),
    PC_ID_5_4 VARCHAR2 (25),
    PC_ID_6_0 VARCHAR2 (25),
    PASSWORD_5_4 VARCHAR2 (25),
    PASSWORD_6_0 VARCHAR2 (25),
    PC_ID_6_1 VARCHAR2 (25),
    PASSWORD_6_1 VARCHAR2 (25),
    OPERATING_SYSTEM VARCHAR2 (20),
    STATUS VARCHAR2 (1)
    Basically, I want to retrieve all columns from the table but remove all duplicate variations of
    the pc_id/serial_nbr combinations.
    For example, given this data:
    PC_ID SERIAL_NBR CUSTOMER_NO
    1234567 AAA C345
    1234567 AAA C567
    3333333 BBB C456
    only the 1st and 3rd rows would be returned.
    Any ideas?

    Try something like this:
    select * from your_table yt
    where rowid in (select max(rowid)
    from your_tabel yt2
    where yt2.pc_id = yt.pc_id
    and yt2.serial_nbr = yt.serial_nbr);

  • How to remove white space between two answer reports

    How to remove white space between two answer reports
    In Dashboard section I have 2 rqeuest. Each request renders Table View. When I display dashboard, it show white space separating the 2 table views. How do I get rid of the white space/white band ?

    See this link
    Re: Eliminating the space between two reports in OBIEE dashboard page Section
    Regards,
    Sandeep

  • Link Between two worksheets in Discoverer

    Hi...
    I'm trying to create a link between two worksheets without success.
    What I have is a 'General Ledger' worksheet which lists the journal source for a particular account code that is selected by the user via a parameter. Say the journal source is Accounts Payable invoices, what I want to do is have another worksheet which is 'Accounts Payable' and on that worksheet I want to be able to list all the invoices that make up the journal total on the 'General Ledger' worksheet.
    I have tried to create a link using a sub query condition but when I run the report, the first part 'General Ledger' works fine but when I click on the 'Accounts Payable', I get a "Invalid Number" error message.
    I am going to need to create these type of links for various reports.
    I would be very grateful if anyone can please advise on how to create the link.
    Thanks

    I think you're on the right track with the subquery. So, the wrong number error must be related to the format of the columsn you use for the subquery.
    Alternatively, if the account number you've created the parameter for in sheet 1, you can use the same parameter again for sheet 2 (then check "only one value for all sheets" for that parameter). But this obviously only works if that account number is in the second sheet too...

  • Need to Remove Duplicate Rows

    I have two tables MEMBER_ADRESS and MEMBER_ORDER. The MEMBER_ADRESS has duplicate rows in it based on MEMBER_ID and MATCH_VALUE. These duplicate ADDRESS_IDs were used in MEMBER_ORDER. I need to remove the duplicates from MEMBER_ADRESS making sure I keep the one with PRIMARY_FLAG = ‘Y’ and update MEMBER_ORDER.ADDRESS_ID to the MEMBER_ADRESS.ADDRESS_ID that I kept.
    I am on 11gR1
    Thanks for the help.
    CREATE TABLE MEMBER_ADRESS
      ADDRESS_ID               NUMBER,
      MEMBER_ID                NUMBER,
      ADDRESS_1                VARCHAR2(30 BYTE),
      ADDRESS_2                VARCHAR2(30 BYTE),
      CITY                     VARCHAR2(25 BYTE),
      STATE                    VARCHAR2(2 BYTE),
      ZIPCODE                  VARCHAR2(10 BYTE),
      CREATION_DATE            DATE,
      LAST_UPDATE_DATE         DATE,
      PRIMARY_FLAG             CHAR(1 BYTE),
      ADDITIONAL_COMPANY_INFO  VARCHAR2(40 BYTE),
      MATCH_VALUE              NUMBER(38) GENERATED ALWAYS AS (TO_NUMBER( REGEXP_REPLACE ("ADDITIONAL_COMPANY_INFO"||"ADDRESS_1"||"ADDRESS_2"||"CITY"||"STATE"||"ZIPCODE",'[^[:digit:]]')))
    Insert into MEMBER_ADRESS
       (ADDRESS_ID, MEMBER_ID, ADDRESS_1, ZIPCODE, CREATION_DATE, LAST_UPDATE_DATE, PRIMARY_FLAG, MATCH_VALUE)
    Values
       (200, 30, '11 Hourse Rd.',
        '58754', TO_DATE('08/11/2011 10:56:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2011 10:34:10', 'MM/DD/YYYY HH24:MI:SS'), 'Y', 1158754);
    Insert into MEMBER_ADRESS
       (ADDRESS_ID, MEMBER_ID, ADDRESS_1, ZIPCODE, CREATION_DATE, LAST_UPDATE_DATE, PRIMARY_FLAG, MATCH_VALUE)
    Values
       (230, 12, '101 Banks St',
        '58487', TO_DATE('08/11/2011 10:56:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2011 10:35:42', 'MM/DD/YYYY HH24:MI:SS'), 'N', 10158487);
    Insert into MEMBER_ADRESS
       (ADDRESS_ID, MEMBER_ID, ADDRESS_1, ZIPCODE, CREATION_DATE, LAST_UPDATE_DATE, PRIMARY_FLAG, MATCH_VALUE)
    Values
       (232, 12, '101 Banks Street',
        '58487', TO_DATE('08/11/2011 10:56:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2011 10:41:15', 'MM/DD/YYYY HH24:MI:SS'), 'N', 10158487);
    Insert into MEMBER_ADRESS
       (ADDRESS_ID, MEMBER_ID, ADDRESS_1, ZIPCODE, CREATION_DATE, LAST_UPDATE_DATE, PRIMARY_FLAG, MATCH_VALUE)
    Values
       (228, 12, '101 Banks St.',
        '58487', TO_DATE('08/11/2011 10:56:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2011 10:38:19', 'MM/DD/YYYY HH24:MI:SS'), 'N', 10158487);
    Insert into MEMBER_ADRESS
       (ADDRESS_ID, MEMBER_ID, ADDRESS_1, ZIPCODE, CREATION_DATE, LAST_UPDATE_DATE, PRIMARY_FLAG, MATCH_VALUE)
    Values
       (221, 25, '881 Green Road',
        '58887', TO_DATE('08/11/2011 10:56:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2011 10:34:18', 'MM/DD/YYYY HH24:MI:SS'), 'Y', 88158887);
    Insert into MEMBER_ADRESS
       (ADDRESS_ID, MEMBER_ID, ADDRESS_1, ZIPCODE, CREATION_DATE, LAST_UPDATE_DATE, PRIMARY_FLAG, MATCH_VALUE)
    Values
       (278, 28, '2811 Brown St.',
        '58224', TO_DATE('08/11/2011 10:56:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2011 10:36:11', 'MM/DD/YYYY HH24:MI:SS'), 'N', 281158224);
    Insert into MEMBER_ADRESS
       (ADDRESS_ID, MEMBER_ID, ADDRESS_1, ZIPCODE, CREATION_DATE, LAST_UPDATE_DATE, PRIMARY_FLAG, MATCH_VALUE)
    Values
       (280, 28, '2811 Brown Street',
        '58224', TO_DATE('08/11/2011 10:56:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2011 10:45:00', 'MM/DD/YYYY HH24:MI:SS'), 'Y', 281158224);
    Insert into MEMBER_ADRESS
       (ADDRESS_ID, MEMBER_ID, ADDRESS_1, ADDRESS_2, ZIPCODE, CREATION_DATE, LAST_UPDATE_DATE, PRIMARY_FLAG, MATCH_VALUE)
    Values
       (300, 12, '3421 West North Street', 'x',
        '58488', TO_DATE('08/11/2011 10:56:25', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('08/12/2011 10:42:04', 'MM/DD/YYYY HH24:MI:SS'), 'Y', 342158488);
    COMMIT;
    CREATE TABLE MEMBER_ORDER
      ORDER_ID    NUMBER,
      ADDRESS_ID  NUMBER,
      MEMBER_ID   NUMBER
    Insert into MEMBER_ORDER
       (ORDER_ID, ADDRESS_ID, MEMBER_ID)
    Values
       (3, 200, 30);
    Insert into MEMBER_ORDER
       (ORDER_ID, ADDRESS_ID, MEMBER_ID)
    Values
       (4, 230, 12);
    Insert into MEMBER_ORDER
       (ORDER_ID, ADDRESS_ID, MEMBER_ID)
    Values
       (5, 228, 12);
    Insert into MEMBER_ORDER
       (ORDER_ID, ADDRESS_ID, MEMBER_ID)
    Values
       (6, 278, 28);
    Insert into MEMBER_ORDER
       (ORDER_ID, ADDRESS_ID, MEMBER_ID)
    Values
       (8, 278, 28);
    Insert into MEMBER_ORDER
       (ORDER_ID, ADDRESS_ID, MEMBER_ID)
    Values
       (10, 230, 12);
    COMMIT;

    Hi John;
    Sorry I missed your post. Yes sorry about the flag. Please take a look as these before and after sets. I hope this helps. I should have posted this in the begining.
    MEMBER_ORDER (BEFORE)
    ORDER_ID  ADDRESS_ID  MEMEBER_ID
    4       228           12
    10       230           12
    5       230           12
    11       232           12
    12       300           12
    8       278           28
    6       278           28
    3       200           30
    MEMBER_ORDER (AFTER)
    ORDER_ID  ADDRESS_ID  MEMEBER_ID
    4       232           12
    10       232           12
    5       232           12
    11       232           12
    12       300           12
    8       280           28
    6       280           28
    3       200           30
    MEMBER_ADDRESS (BEFORE)
    ADDRESS_ID  MEMBER_ID  ADDRESS_1                    CREATION_DATE             LAST_UPDATE_DATE   PRIMARY_FLAG  MATCH_VALUE
    228         12           101 Banks St.                  8/11/2000 10:56:25 AM     8/12/2005 10:38:19 AM     N     10158487
    230         12           101 Banks St                   8/11/2000 10:56:25 AM     8/12/2006 10:35:42 AM     N     10158487
    232         12           101 Banks Street             8/11/2000 10:56:25 AM     8/12/2007 10:41:15 AM     N     10158487
    300         12           3421 West North Street       8/11/2000 10:56:25 AM     8/12/2011 10:42:04 AM     Y     342158488
    221         25           881 Green Road               8/11/2000 10:56:25 AM     8/12/2011 10:34:18 AM     Y     88158887
    278         28           2811 Brown St.               8/11/2000 10:56:25 AM     8/12/2006 10:36:11 AM     N     281158224
    280         28           2811 Brown Street               8/11/2000 10:56:25 AM     8/12/2011 10:45:00 AM     Y     281158224
    200         30           11 Hourse Rd.                  8/11/2000 10:56:25 AM     8/12/2005 10:34:10 AM     Y     1158754
    MEMBER_ADDRESS (AFTER)
    ADDRESS_ID  MEMBER_ID  ADDRESS_1                    CREATION_DATE             LAST_UPDATE_DATE    PRIMARY_FLAG  MATCH_VALUE
    232         12           101 Banks Street                8/11/2000 10:56:25 AM     8/12/2007 10:41:15 AM     N     10158487
    300         12           3421 West North Street       8/11/2000 10:56:25 AM     8/12/2011 10:42:04 AM     Y     342158488
    221         25           881 Green Road                8/11/2000 10:56:25 AM     8/12/2011 10:34:18 AM     Y     88158887
    280         28           2811 Brown Street              8/11/2000 10:56:25 AM     8/12/2011 10:45:00 AM     Y     281158224
    200         30           11 Hourse Rd.                8/11/2000 10:56:25 AM     8/12/2005 10:34:10 AM     Y     1158754

  • Need to remove duplicate rows from a table

    Hi Gurus ,
    I am using oracle 11.2.0.3 .
    SQL> desc osstage.S_EVT_ACT_X;
    Name                                      Null?    Type
    ROW_ID                                    NOT NULL VARCHAR2(15 CHAR)
    LAST_UPD                                  NOT NULL DATE
    PAR_ROW_ID                                NOT NULL VARCHAR2(15 CHAR)
    ATTRIB_17                                          NUMBER(22,7)
    ATTRIB_26                                          DATE
    ATTRIB_02                                          VARCHAR2(100 CHAR)
    PROCESS_TIMESTAMP                                  TIMESTAMP(6);
    now when i give the below command it gives the error as someone has disabled the constraint accidently .
    alter table s_evt_act_x enable constraint S_EVT_ACT_X_P1;
    Error starting at line 3 in command:
    alter table s_evt_act_x enable constraint S_EVT_ACT_X_P1
    Error report:
    SQL Error: ORA-02437: cannot validate (OSSTAGE.S_EVT_ACT_X_P1) - primary key violated
    02437. 00000 -  "cannot validate (%s.%s) - primary key violated"
    *Cause:    attempted to validate a primary key with duplicate values or null
               values.
    *Action:   remove the duplicates and null values before enabling a primary
               key.
    Can you please guide me with this issue .

    Please refer
    Script: Deleting Duplicate Rows from a Table (Doc ID 31413.1)
    How to Find or Delete Duplicate Rows in a Table (Doc ID 1004425.6)

  • Remove duplicate rows

    If any duplicate rows exist in the table I wanna delete the oldest rows between 2007-01-01 and 2007-12-31. The latest row I wanna keep. Is this the right way to do this:
    Delete from tblSalesInfo
    Where ROWID NOT IN (SELECT Max(ROWID) FROM tblSalesInfo  GROUP BY salesorder, salesorder_item, orderquantity, line)
    And rec_date between to_date('2007-01-01','yyyy-mm-dd') And to_date('2007-12-31','yyyy-mm-dd')
    And comments Is Null;

    Ok, perhaps i should have explained what i sent you does.
    The inner most select partitions out the data into "groups" much like your group by clause does. It assigns a number to each row 1, 2, 3, ..... N over that partition, when a new partition comes about it starts ordering the data again.
    for example.....
    ME_XE?create table test (column1 varchar2(10), column2 varchar2(20));
    Table created.
    Elapsed: 00:00:00.04
    ME_XE?insert into test values ('row1', 'not a dup yet');
    1 row created.
    Elapsed: 00:00:00.00
    ME_XE?insert into test values ('row1', 'dup');
    1 row created.
    Elapsed: 00:00:00.00
    ME_XE?insert into test values ('row2', 'all alone');
    1 row created.
    Elapsed: 00:00:00.00
    ME_XE?
    ME_XE?select row_number() over (partition by column1 order by column2 asc) as THE_ROWNUMBER, column1, column2
      2  from test;
         THE_ROWNUMBER COLUMN1                        COLUMN2
                     1 row1                           dup
                     2 row1                           not a dup yet
                     1 row2                           all alone
    3 rows selected.
    Elapsed: 00:00:00.01So what you want to do in order to identify duplicates is say
    1) assign a row number to each set of values that i define to be a duplicate
    2) keep all the rowids that are duplicates
    3) delete from the table where the ROWID matches all the kept rowids from step 2.
    make more sense?

  • Removing Weekends in between two dates

    Hi,
    I need to get the number of days in between two dates excluding the weekends.
    Does anyone know how to do this?
    Thanks.

    Here's a search of the forum for "difference dates". At least the first three questions are identical to yours.
    http://search.java.sun.com/Search/java?col=javafrm&qp=%2Bforum%3A31&qt=difference+dates&x=12&y=10

  • Special case of removing duplicate rows ...

    There is small issse that we are facing in SQL.
    We have a table say A which has a two column ACOL1 and ACOL2.
    The datatype of ACOL1 column is char(6). This column also has a PK constraint on it. The ACOL2 has a varchar2 datatype.
    Table A contains values like:
    ACOL1 | ACOL2
    12345 | Check the BOL rate
    012345 | not_in_use.
    Now we want to change the COL1 datatype to number(6). We take a backup of this table , disable the PK constraint on COL1,change the datatype of COL1, insert into this table from the backup and enable the PK. It gives a PK violation message which it should. So far so good.
    To remove the duplicate values in the table before enabling the PK we used the following query:
    delete from A t1
    where exists (select 'x' from A t2
    where t2.message_id = t1.message_id
    and t2.rowid > t1.rowid)
    This SQL removes the duplicate COL1 value but the PROBLEM is that it does so randomly and what we need is to just delete that duplicate record which starts with zero.
    But while changing the datatype of the COL1 to number and copying from the backup table into table A , the leading zero get automatically truncated.
    How can we delete only that duplicate record which start with 0 like 012345 in the above given scenario?
    Thanks for your help.

    This should work for you, assign row number based on the PK value, then order by the first character of the PK.
    NOTE: if you have more instances (say 3) of the identical PK value you may want to do some modifications to this...
    ME_XE?create table Test_1
    2 (
    3 col1 varchar2(10) primary key,
    4 col2 varchar2(10)
    5 );
    Table created.
    Elapsed: 00:00:00.09
    ME_XE?
    ME_XE?insert into Test_1 (col1, col2) values ('123', 'Important');
    1 row created.
    Elapsed: 00:00:00.06
    ME_XE?insert into Test_1 (col1, col2) values ('0123', 'Not Imp');
    1 row created.
    Elapsed: 00:00:00.06
    ME_XE?insert into Test_1 (col1, col2) values ('01299', 'keeper');
    1 row created.
    Elapsed: 00:00:00.09
    ME_XE?
    ME_XE?create table test_2 as
    2 select col1, col2
    3 from
    4 (
    5 select
    6 col1,
    7 col2,
    8 row_number() over (partition by to_number(col1) order by substr(col1, 1, 1) desc) as the_rownum
    9 from test_1
    10 )
    11 where the_rownum = 1;
    Table created.
    Elapsed: 00:00:00.07
    ME_XE?
    ME_XE?drop table test_1;
    Table dropped.
    Elapsed: 00:00:00.12
    ME_XE?alter table test_2 rename to test_1;
    Table altered.
    Elapsed: 00:00:00.06
    ME_XE?select * from test_1;
    COL1 COL2
    123 Important
    01299 keeper
    2 rows selected.
    Elapsed: 00:00:00.15

  • How to compare data between two worksheet in Excel for applescript

    Hi All,
    How to compare the data from two different worksheet in Excel and set the value into one worksheet according to the same name? Here is the example. Worksheet 1 & 2 current we have, the final worksheet is the result we want and the value can be input in worksheet 1. Much appreciate if you can help on it.
    Worksheet 1:
    Name          Number
    Leo                 25
    Jame               55
    Leo                 30
    Jame               60
    Tim                 44
    Tomas             77
    Lyne                35
    Tonny              66
    Jame               22
    Game              88
    Worksheet  2:
    Name          Number  2
    Leo                60
    Jame             150
    Tim                66
    Tomas            88
    Lyne               55
    Tonny            99
    Game             111
    Rusult in Worksheet 1
    Name          Number        Total Number per name in Worksheet 1         Number 2 in Worksheet 2
    Leo                 25                          55                                                        60
    Jame               55                         137                                                       150
    Leo                 30                           55                                                        60
    Jame               60                         137                                                       150
    Tim                 44                          44                                                         66
    Tomas             77                          77                                                        88
    Lyne                35                          35                                                        55
    Tonny              66                          66                                                        99
    Jame               22                         137                                                       150
    Game              88                          88                                                        111

    I'd probably use a database for this, if there's any quantity of data involved here.  Import from Excel into {SQLite, MySQL, PostgreSQL, FileMaker, maybe Core Data}, or pick your preferred key-value store, keep your data in the database, then export or (via ODBC/JDBC) then access live database data from within the spreadsheets.
    Alternatively and if you're looking at small quantities of data (say, less than 10,000 entries, or less than a thousand depending on the language), then just use whatever passes for a key-value store in your preferred scripting language {Python, bash, Lua, or maybe php, AppleScript or Java} and use that.  Export Excel to CSV {gag} or XML, then load that into Python and process as needed, then write out CSV {gag} or XML.
    AppleScript is a scripting language for GUI applications, and also useful for processing events.  If you're not doing that sort of stuff, then there can be other choices, and other choices can often have extensive frameworks and libraries for common tasks.
    Sooner or later, most everybody runs into a wall when using a spreadsheet...  Various folks have encountered those limits and have migrated from spreadsheets to FileMaker databases, and now use a database as the central store for their operations — and that's the other issue that can arise with spreadsheets... Where's the canonical data?

  • Remove duplicates rows by date (min)

    I customer dimension where the customer can be identified by three kind of numbers different. 
    I have to load this dimension whithout customer duplicates, and the identified number can exist or not.
    for example
    id1    id2    id3       date 
    122  null null      2014/02/01
    122   22 null     2014/02/02
    123    null   333     2014/12/01
    nulll     333 null     2014/12/23
    null     null  333      2014/11/23
    I want first row for each customer, after I need make a ssc type 1.
    the result would is:
    id1    id2    id3       date 
    122   22    null     2014/02/02
    null     null  333      2014/11/23
    nulll    333  null     2014/12/23
    best regards
    thanks, David

    I have a mistake, the result will have be :
    id1    id2    id3       date 
    122  null null      2014/02/01
    null     null  333      2014/11/23
    nulll    333  null     2014/12/23
    sorry

  • Remove Duplicate Rows from Left Outer Join

    Hi All,
    I am new to Oracle..I have two tables as follow:
    TableA(EmpID, Empname)
    TableB(EmpID, DeptID, DeptName). A employee can work in multiple dept.
    table A has 1 row as EmpID 1 and TableB has two rows for EmpID 1.
    I have a search page which takes dept ID as parameter and return employee name...Dept ID is not mandatory feld for Search. If DeptID is passed it should return the employee who belongs to that Dept otherwise it should return 1 employee..
    Now I have used as follow:
    :IN_DEPTID is passed as parameter
    Select EmpName from TableA Left Join tableB on a.EmpID = B.EmpID
    WHERE
    CASE WHEN :IN_DEPTID IS NULL
    IN_DEPTID IS NULL
    ELSE|
    DEPTID = :IN_DEPTID
    Now problem is when Dept ID is passed it correctly returns a row but if no deptid is passed it returns 2 rows but i want ony one row as there is only one employee.
    Please help;
    Edited by: user10239708 on 10 Sep, 2008 12:24 AM
    Edited by: user10239708 on 10 Sep, 2008 12:28 AM

    Try this
    Select
    from
         tableA a
    where
         (exists (select 1 from tableB b where a.empid = b.empid and deptid = :IN_DEPTID )
         or
         :IN_DEPTID is null) you database design is not good you should keep the emp, department mapping in different table.
    Regards
    Singh

Maybe you are looking for

  • Need Help - Installation failing at:  Phase 25 Intsall instance basics

    Hello everyone, We are trying to install solution manager 4 on linux readhat E4 (oracle db).  Currently, we are stuck at phase 25 "install instance basics.   I can see at the bottom of the screen, the message says the phase is "Creating instance dire

  • *ERROR* FX-300 Timeid=20110200 - Nothing Extract from Fact - CLCFXTRANS

    Hi Friends I am getting and error while i am running FX Restatement Package.below is my error message. I even analyzed the notes and some threads, there is no solution. Most of the threads says its missing rates in Rate application, but still i am ma

  • Allowing .exe file attachments to open in PDFs - creating reg key

    Hi, I'm creating some user support material and have attached .exe files to PDFs. As this is a black-listed file type the files will not run from the PDF. I've checked the registry keys and the FeatureLockDown key has an empty default key when I expe

  • Numeric literal from string

    Hi, I have a string which contains the name of the customer, followed by phone number. There is no specific length for the name part and the tel number( I cannot use the substring method directly). The tel number is sometimes followed by address( can

  • SAPscript: breakpoint in print program

    Hi all, I have put a breakpoint (tried both hardcoded and session break) in my print program of my SAPscript, but it is not 'breaking' at that point. I am sure this is the correct print program and have also looked in the forums, but have found nothi