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

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)

  • 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);

  • 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

  • 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

  • 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

  • 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 duplicates while loading data from text file

    Hi,
    Data in text file (some times has duplicates) is being loaded into Oracle 9i database using Informatica. To improve performance, we would like to remove duplicates at the time of each load using Oracle procedure. Could you please help me with this?
    Thanks,
    Lakshmi

    No, our table doesn't have that. Most of the functionality is managed at the informatica level. Is there any other way? Thanks,

  • Delete Duplicate rows in Data Package based on selection

    Hello experts,
    I have the data coming from Oracle using DB_Connect. The data has duplicate order no. I need to delete the duplicate rows in the data package based selection before updating the data target.
    I am thinking of writing this in updaterule start routine. I would greatly appreciate any sample code on selective deletion of data package rows.
    Thanks a lot!
    Sri

    Nagesh,
    Thanks for your reply.
    Do I need write this in Update Start routine?
    Another thing the order number field is coming from source system. Currently we are not mapping/assingning to InfoObject. In other words we are not seding order no to data target.
    In my query can I write something like this...
    DELETE ADJACENT DUPLICATES FROM DATA_PACKAGE COMPARING DATA_Package-OrderNo
    Thanks a lot!
    Sri

  • 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?

  • Remove duplicate rows based on latest date

    Hi Julius, There are various ways to achive this but I would think an optimized way of doing it by making use of (Sorter and) an Aggregator transformation(s), see how.. Sort your input records at SQ level if it's a relational source or else use a Sorter tx (that's why I mentioned Sorter tx in braces in abvoe line) to sort the input rows on Stage_ID and Date, both in Ascending order, thus you get the latest date record at the end in the list per common Stage_IDs. Now, connect to Aggregator (must be right next to the sorter in order to not to loose the sorted data), and enable the Group By for Stage_ID port. By nature, aggregator tx will push the last record of the group by port or last record of the complete data set if no group by port mentioned. So, you will get recent row per Stage_ID. Try and get back to us if you have any questions or run into issues,-Rajani

    I have a target table I need to split up: stage_id / date / case / blah / blah100 / 01-jan-2015 / 223 / 32 / 323100 / 01-apr-2015 / 224 / 32 / 322 the stage_id column cannot have more than 1 of the same record, so, i need to keep the latest record (01-apr-2015) in this target table, then remove the old one and put it into a dimension table any suggestions for how to accomplish this? please let me know if more info is needed thanks!

  • 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

  • Removing Duplicate Rows from resultSet

    I have a query pulling data from 5 tables in 12 columns. I have rows where all of the data is duplicated with the exception of one date column. How would I go about deleting rows that are duplicates with the exception of this one column? I still need to pull the date from the date column with the Max(date).
    i.e.
    Bob Smith 1 2 3 4 12-Jul-2006
    Bob Smith 1 2 3 4 02-Aug-2006
    Bob Smith 1 2 3 4 21-Jan-2006
    Form this resultset I only want one row
    Thanks.

    this example might be of help.
    SQL> select * from employees;
    YEAR EM NAME       PO
    2001 02 Scott      91
    2001 02 Scott      01
    2001 02 Scott      07
    2001 03 Tom        81
    2001 03 Tom        84
    2001 03 Tom        87
    6 rows selected.
    SQL> select year, empcode, name, position,
      2         row_number() over (partition by year, empcode, name
      3                            order by year, empcode, name, position) as rn
      4    from employees;
    YEAR EM NAME       PO         RN
    2001 02 Scott      01          1
    2001 02 Scott      07          2
    2001 02 Scott      91          3
    2001 03 Tom        81          1
    2001 03 Tom        84          2
    2001 03 Tom        87          3
    6 rows selected.
    SQL> Select year, empcode, name, position
      2    From (Select year, empcode, name, position,
      3                 row_number() over (partition by year, empcode, name
      4                                    order by year, empcode, name, position) as rn
      5            From employees) emp
      6   Where rn = 1;
    YEAR EM NAME       PO
    2001 02 Scott      01
    2001 03 Tom        81
    SQL> Delete From employees
      2   Where rowid in (Select emp.rid
      3                     From (Select year, empcode, name, position,
      4                                  rowid as rid,
      5                                  row_number() over (partition by year, empcode, name
      6                                            order by year, empcode, name, position) as rn
      7                             From employees) emp
      8                    Where emp.rn > 1);
    4 rows deleted.
    SQL> select * from employees;
    YEAR EM NAME       PO
    2001 02 Scott      01
    2001 03 Tom        81
    SQL> if you can post a sample create tables and data it will help us provide you a some solutions.

  • Duplicate rows and data across multiple pages.

    My form has 12 pages (each page = 1 month). With a loop, the pages are hidden until the corresponding button is clicked and it becomes visible (Thanks Assure Dynamics for a great solution to a very long form).
    In Month 1, I have a table with a repeating row. What I would like to do is copy the repreating row and it's data to Month 2. Then I would like to have the table from Month 2, duplicate to Month 3, Month 3 to Month 4 and so on.
    I have been able to get the row from Month 1 to duplicate in Month 2 on the exit event of each cell in the row, however, when you are in Month 2 and do not change a cell which was created in Month 1, the data does not duplicate into the next month (Month 3). Instead of on the exit event of the cell(field), I thought placing it on a button would work but it is not.
    This is what I used on the exit event in the table for Month 1:
    xfa.resolveNode("Month2.Performancegoals2.updates.details[" + this.parent.index + "]").projectName.rawValue = this.rawValue;
    I also thought instead of using a table and a repeating row, I could place the information in a repeating subform but I am still stuck with how to copy the subform and its completed data to the next month.
    I am really stuck and have been looking for hours for a solution. Can anyone help, I am out of time for the deadline of this form.?

    Hi,
    Firstly,you must do the count of the table.
    frmTableBlock.tblTableMonth2._rowItem.count = frmTableBlock.tblTableMonth1._rowItem.count
    frmTableBlock.tblTableMonth12._rowItem.count = frmTableBlock.tblTableMonth1._rowItem.count
    And write the code which is do you want to copy the data Month1 to month12.
    I hope
    S,Candy

  • 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

  • Is there any way to embed chord information in a song?

    Can Logic Pro X embed 'chord change' information in a song in some way?  For example, is there an a simple obvious way, like a 'chord information global  track',  that I'm overlooking?  Or is there a more convoluted way to get chord information in a

  • A few Web Gallery Questions

    1) I have an Event with 49 photos I'm trying to upload to the Web Gallery. It seems it will upload only one & then stop. I see nothing that says pending or indicates it's still uploading. I've tried a few times with the same results 2) The one pictur

  • Trouble Installing CS4 on Mac Book Pro with Lion 10.7.3

    Hello, I'm having trouble with this. As instructed by Adobe I'm working with the original CD to install this to my laptop. It goes up to installing Adobe Air, about half way through the whole installation and then stops. I have tried resetting the pe

  • How Do I Join a Workstation to a Domain

    I'm trying to join a workstation to my domain (Server 2012 R2 Foundation).  I've set the workstation up with a static internal IP address (192.168.1.2), and can both ping the server from the workstation and the workstation from the server.  When I go

  • Ibatis on NetWeaver

    Hi, I have a J2EE application on NetWeaver using JDBC. I move this application on Hibernate and everything works. Now, I want to change JDBC by Ibatis, an other persistence framework and I have some difficulties. Indeed, the load of the configuration