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)

Similar Messages

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

  • 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 a row from multiple tables

    Hello,
    I have a form that has what appears to be one table.  Since I needed 30 columns (29 of them are single character fields) I had to use 2 table objects.  Then I needed the ability to add and remove rows.  Adding a row at the end is easy enough.  Deleting a specific row is the problem.  At the moment, I added a third table which has a header row and a item body row.  the body row is a button with the intention of removing that entire row from the large table.  This means it needs to remove the row from all 3 tables.
    My structure is:
    form1
    (Some other flowed subform that doesn't matter for us)
    SubformPersonnel (a flowed subform)
    SubformHeader (a positioned subform)
    TextOverallHeader (text to label the oeverall 3 tables)
    ButtonAddRow (adds a row to the end of all 3 tables)
    SubformPersonnelTable (a positioned subform)
    ContractorTableRemove (a table with 1 column for the Remove button)
    HeaderRow (A hidden row to align the table with the other 2)
    Item (A row with the Remove button)CellRemoveButton (the cell with the remove button and associated JavaScript)
    ContractorTableLeft (a table with the left 15 printed columns)
    HeaderRow
    Contractor (A row of data to be removed when CellButton above is clicked)
    ContractorTableRight (a table with the right 15 printed columns)
    HeaderRow
    Contractor (A row of data to be removed when CellButton above is clicked)
    (Some other flowed subforms that I am not worried about at the moment)
    The 3 tables are aligned so the headers all line up, with no spaces between them.  The body rows then line up and this looks like one large table.  From left to right, they are:
    ContractorTableRemove, ContractorTableLeft, ContractorTableRight
    So Item and Contractor rows are added when ButtonAddRow is clicked in the overall header.  The intial count is set to 8 for each table, so I get 8 rows at startup. The minimum count is set to 1 for each.  I know that each row of each table has the same index number because I filled those into a cell in each table durig the cell's initialize.  This line, in the CellRemoveButton's click event deletes that cell's row in that table:
    this.parent.parent._Item.removeInstance(this.parent.index);
    I have tried all sorts of ways to delete the same row (using same index #) in the other 2 tables: ContractorTableLeft and ContractorTableRight, but don't seem to be getting the correct syntax correct.  I have tried hard coding the references, using .parent as shown below, and also tried using an index of 1 just to try deleting a row with no results.
         this.parent.parent.parent.ContractorTableLeft._Contractor.removeInstance(this.parent.inde x);
    Can someone get me the correct syntax here?
    I have seen examples of putting a hidden delete button on each table and clicking that, but I am concerned that it will get in the way of the tables on either side of the table it is in.  I reeally want to just reference the row and remove it so I can avoid any problems these additional delete problems may cause.
    I have copied the form to https://acrobat.com/#d=7M8R50rEHf4AaVXppwyKLw

    Thank you, Niall.  Much appreciated!
    The Delete button was more to make sure one could delete these outside a button in the actual row and I see I had the index wrong such that I was deleting the second row and not the first.  I had toyed with using this as a hidden button if I could pass the index to the event's function.
    I had not thought of adding the reference to each row as a variable.  It seems to work very well.
    For future reference to others, here is the code from the cellRemoveButton click event:
         // Declare some variables
         var i = this.parent.index;
         var oContractorLeft = ContractorTableLeft.Contractor;
         var oContractorRight = ContractorTableRight.Contractor;
         // Remove this row by accessing its index within the set of 'Item' row instances of the parent table
         _Item.removeInstance(i);
          // Since this table is actually 3 tables, we need to remove the other two table's instances as well.
         // Their index should be the same, so we just need to get their names correct.
         oContractorLeft.instanceManager.removeInstance(i);
         oContractorRight.instanceManager.removeInstance(i);
          // removing the row doesn't trigger calculations in tables in the form's current target (fixed in later versions of Acrobat)
         // force calculations to fire so the ItemIndex field's value is updated according to the remaining row's indexes
         // see http://forms.stefcameron.com/2006/05/20/add-recalculate/
         xfa.form.recalculate(1);
    Again, thank you!
    Karl

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

  • How to delete the duplicate rows from the table

    Hi,
    I have 2 tbales namely component, component_audit
    For each record in component table there are multiple entries in component_audit table.
    I need to keep the first record and delete the others from the component_audit table
    say for example
    select a.component_id,a.dt_ti_stamp,a.component_name,a.column_before,b.comments from component_audit a,component b where a.component_id=b.component_id
    ( on the above result set only I shold apply the actual delete query )
    PLease help me in this regards.
    Thanks.

    delete from component_audit a where dt_ti_stamp not in (select
                                            min(b.dt_ti_stamp)
                                       from
                                            component_audit b
                                       where
                                            a.component_id = b.component_id)

  • Need to remove duplicate rows from distinct query

    Hello,
    I have the following query:
    SELECT tiab.abnr abnr, tiab.namn namn, (CAST(tiab.GATUNR||' '||tiab.gata AS VARCHAR2(254))) ADR, tiab.boxpnr boxpnr, tiab.boxort boxort,
              (CAST(tiab.RIKTNRDISPLAY AS VARCHAR2(254))) RIKTNR, (CAST(tiab.TELNRDISPLAY AS VARCHAR2(254))) TELNR,
    DECODE((select count(tior.tigilopnr) from tis.tior where abnr = tiab.abnr and inplnr IN (3797886)),0 ,NULL , 1, tior.tigilopnr, 'N/A') tigilopnr
              FROM tis.tiab
    JOIN tis.tior on tiab.abnr = tior.abnr
              WHERE tior.inplnr IN (3797886)
              ORDER BY tiab.ABNR )
    ORDER BY abnr;
    It returns the following:
         14684940     Pizza Station Inc The     Lafayette     26170      St Marys     304     684-2411     
         15123161     Chris Test     554 Easy St n 43333      Columbus     614     555-5555     
         15123162     Chris Test2     5556 Easy St     43333     Columbus     614     555-5151     2553304 --> keep this one
         15123162     Chris Test2     5556 Easy St     43333     Columbus     614     555-5151     -- not show this
    I have tried several different things as well as looking through the forums but have not found anything that will only give me unique records based only on the first column. This query works fine as long as there
    are not 2 records returned with column1 being identical.
    Final results should look like this:
         14684940     Pizza Station Inc The     Lafayette     26170      St Marys     304     684-2411     
         15123161     Chris Test     554 Easy St n 43333      Columbus     614     555-5555     
         15123162     Chris Test2     5556 Easy St     43333     Columbus     614     555-5151     2553304
    Thanks in advance for the assistance.

    Hello,
    Try:
    SELECT  abnr, namn, ADR,  boxpnr,  boxort,RIKTNR,  TELNR,tigilopnr
      FROM (
    SELECT tiab.abnr abnr, tiab.namn namn, (CAST(tiab.GATUNR||' '||tiab.gata AS VARCHAR2(254))) ADR, tiab.boxpnr boxpnr, tiab.boxort boxort,
    (CAST(tiab.RIKTNRDISPLAY AS VARCHAR2(254))) RIKTNR, (CAST(tiab.TELNRDISPLAY AS VARCHAR2(254))) TELNR,
    DECODE((select count(tior.tigilopnr) from tis.tior where abnr = tiab.abnr and inplnr IN (3797886)),0 ,NULL , 1, tior.tigilopnr, 'N/A') tigilopnr,
    ROW_NUMBER () OVER (PARTITION BY tiab.abnr ORDER BY (CAST(tiab.TELNRDISPLAY AS VARCHAR2(254))) NULLS LAST) row_num
    FROM tis.tiab
    JOIN tis.tior on tiab.abnr = tior.abnr
    WHERE tior.inplnr IN (3797886))
    WHERE row_num <= 1
    ORDER BY abnr;Or, with your current query:
    SELECT  abnr, namn, ADR,  boxpnr,  boxort,RIKTNR,  TELNR,tigilopnr
      FROM (
    SELECT distinct tiab.abnr abnr, tiab.namn namn, (CAST(tiab.GATUNR||' '||tiab.gata AS VARCHAR2(254))) ADR, tiab.boxpnr boxpnr, tiab.boxort boxort,
    (CAST(tiab.RIKTNRDISPLAY AS VARCHAR2(254))) RIKTNR, (CAST(tiab.TELNRDISPLAY AS VARCHAR2(254))) TELNR,
    DECODE((select count(tior.tigilopnr) from tis.tior where abnr = tiab.abnr and inplnr IN (3797886)),0 ,NULL , 1, tior.tigilopnr, 'N/A') tigilopnr,
    ROW_NUMBER () OVER (PARTITION BY tiab.abnr ORDER BY (CAST(tiab.TELNRDISPLAY AS VARCHAR2(254))) NULLS LAST) row_num
    FROM tis.tiab
    JOIN tis.tior on tiab.abnr = tior.abnr
    WHERE tior.inplnr IN (3797886))
    WHERE row_num <= 1
    ORDER BY abnr;

  • 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

  • How to remove empty row from rfc table output.

    Hello,
      I am using adaptive rfc and printing table output. The table rows start from 2nd row, the first row being empty. How can I remove the empty first row.
    Here is what I tried.
    wdContext.nodeDataSource().nodeTableOutput().moveNext();
    and
    wdContext.nodeDataSource().nodeTableOutput().moveTo(1);
    Neither of them worked. Any clue is appreciated.
    Srinivas

    IWDNodeElement first = wdContext.nodeDataSource().nodeTableOutput().getElementAt(0);
    wdContext.nodeDataSource().nodeTableOutput().removeElement(first);
    Armin

  • Identifying and reporting Duplicate rows from table

    I want to fetch all the duplicate row from the table and need to report all of it.
    I am trying to run the below query but and not getting the expected output. Please help me.
    Query
    SELECT * FROM ADDT_RPT_REQ A WHERE
    TRIM(A.EMAIL_ADDR) IN
    (SELECT TRIM(EMAIL_ADDR) FROM ADDT_RPT_REQ B
    WHERE TRIM(B.EMAIL_ADDR) = TRIM(A.EMAIL_ADDR)
    AND A.ph_num IN
    (SELECT PH_NUM FROM ADDT_RPT_REQ B
    WHERE TRIM(A.PH_NUM ) = TRIM(B.PH_NUM)
    There are in all 7 columns in the table where id is Unique Id.
    The expected output is something like.
    FST_NAME     LAST_NAME     EMAIL_ADDR     WORK_PH_NUM     ROW_ID     LAST_UPD     BU_ID
    VALERIE     HALL     [email protected]     7819370177     2-21N-4312     31-AUG-04     0-R9NH
    VALERIE     HALL     [email protected]     7819373737     2-21N-4327     29-JAN-04     0-R9NH
    VALERIE     HALL     [email protected]     6034272034     2-21N-4309     04-APR-03     0-R9NH
    VALERIE     HALL     [email protected]     7819373737     2-21N-4317     04-APR-03     0-R9NH
    VALERIE     HALL     [email protected]     8563748820     2-21N-4329     31-AUG-04     0-R9NH
    VALERIE     HALL     [email protected]     7819373737     2-21N-4319     04-APR-03     0-R9NH
    VALERIE     HALL     [email protected]     7819373737     2-21N-4326     04-APR-03     0-R9NH
    VALERIE     HALL     [email protected]     7819373737     2-21N-4324     04-APR-03     0-R9NH
    VALERIE     HALL     [email protected]     8604237395     2-21N-4330     31-AUG-04     0-R9NH
    VALERIE     HALL     [email protected]     7819373731     2-21N-4314     31-AUG-04     0-R9NH
    VALERIE     HALLORAN     [email protected]     6194771101     2-21N-4331     31-OCT-05     0-R9NH
    VALERIE     HALL     [email protected]     7819373737     2-21N-4316     04-APR-03     0-R9NH
    VALERIE     HALL     [email protected]     7819373737     2-21N-4321     04-APR-03     0-R9NH
    VALERIE     HALL     [email protected]     7819373737     7-1W4N-293     15-MAY-04     0-R9NH
    VALERIE     HALL     [email protected]     2032341604     2-21N-4307     31-AUG-04     0-R9NH
    VALERIE     HALL     [email protected]     7819373737     2-21N-4325     04-APR-03     0-R9NH
    VALERIE     HALL     [email protected]     7819373737     2-21N-4315     29-JAN-03     0-R9NH
    VALERIE     HALL     [email protected]     7819373737     7-1W4N-291     15-MAY-04     0-R9NH
    VALERIE     HALLORAN     [email protected]     6194771101     2-21N-4332     31-OCT-05     0-R9NH
    VALERIE     HALL     [email protected]     6038885349     2-21N-4310     31-AUG-04     0-R9NH
    VALERIE     HALL     [email protected]     7819373737324     2-21N-4328     31-AUG-04     0-R9NH
    VALERIE     HALL     [email protected]     7819370177324     2-21N-4313     31-AUG-04     0-R9NH

    Hi again!
    Try that:
    SELECT rowid, fst_name, last_name, email_addr, work_ph_num, row_id, last_upd, bu_id
    FROM ADDT_RPT_REQ A
    WHERE rowid > (SELECT MIN(rowid)
                   FROM ADDT_RPT_REQ B
                   WHERE B.fst_name = A.fst_name
                     AND B.last_name = A.last_name
                     AND B.email_addr = A.email_addr
                     AND B.work_ph_num = A.work_ph_num
                     AND B.row_id = A.row_id
                     AND B.last_upd = A.last_upd
                     AND B.bu_id = A.bu_id);This query should show you all duplicate rows. Use the rowid and DELETE to get rid of these rows.
    DELETE FROM addt_rpt_req A
    WHERE rowid IN (SELECT rowid
                    FROM   (SELECT rowid, row_number() OVER (PARTITION BY fst_name, last_name, email_addr, work_ph_num, row_id, last_upd, bu_id
                                                             ORDER BY row_id) dup
                            FROM addt_rpt_req)
                            WHERE dup > 1);Yours sincerely
    Florian W.
    Edited by: Florian W. on 17.06.2009 14:17

  • Trick to remove duplicate entries from tables ?

    hi.
    i have 53tables which are having duplicate entries and names of all 53 tables r listed in top_t table ?
    can any1 provide me solution to show and if possible ask for remove of those duplicates entries from each table if required ?
    daily i am removing duplicates manually ....its too tedious now !
    can any1 help me out ?

    Well, I suppose if the duplication is such that
    SELECT DISTINCT * FROM tablename;gives you the required result, then you could have a procedure that made a copy of the table, deleted/truncated the original, then inserted the distinct values back into it.
    In 10g you could even use flashback to avoid the temp copy - but it also means you can't use TRUNCATE so whether it's any more efficient I'm not sure. But just for fun and since it's urgent:
    CREATE OR REPLACE PROCEDURE dedupe_table
        ( p_table_name user_tables.table_name%TYPE )
    IS
        k_start_timestamp TIMESTAMP := SYSTIMESTAMP;
    BEGIN
        SAVEPOINT start_of_dedupe;
        BEGIN
            EXECUTE IMMEDIATE 'DELETE ' || p_table_name;
        EXCEPTION
            WHEN OTHERS THEN
                ROLLBACK TO start_of_dedupe;
                RAISE_APPLICATION_ERROR
                ( -20000
                , 'Error deleting ' || UPPER(p_table_name) ||
                   CHR(10) || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE
                , TRUE );
        END;
        BEGIN
            EXECUTE IMMEDIATE
            'INSERT INTO ' || p_table_name ||
            ' SELECT DISTINCT * FROM ' || p_table_name || ' AS OF TIMESTAMP :b1'
            USING k_start_timestamp;
        EXCEPTION
            WHEN OTHERS THEN
                ROLLBACK TO start_of_dedupe;
                RAISE_APPLICATION_ERROR
                ( -20000
                , 'Error repopulating ' || UPPER(p_table_name) ||
                   CHR(10) || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE
                , TRUE );
        END;
    END dedupe_table;
    SQL> select * from wr_test;
          COL1 C C
             1 A B
             1 A B
             2 C D
             2 C D
    4 rows selected.
    SQL> BEGIN
      2      dedupe_table('WR_TEST');
      3  END;
      4  /
    PL/SQL procedure successfully completed.
    SQL> select * from wr_test;
          COL1 C C
             1 A B
             2 C D
    2 rows selected.I make no claims for robustness, efficiency or human safety.
    Edited by: William Robertson on Sep 24, 2009 7:12 PM

  • How to remove a row from a rowset

    HI,
    I am trying to do a very simple thing, but I got stuck.
    The problem:
    I want to remove a row from a rowset, without removing the row itself. Especially I do not want to remove any entities.
    I need this functionality in several situations, for example when I want to move a row from one rowset to another.
    Another situation is when I have a viewlink not based on an association. When a row is modified so it does not fit to the viewlink's where clause anymore, I need a way to remove it manually (without removig any associated entities),
    I hope someon can help me on this,
    thanks,
    Frank

    Sascha:
    The only workaround I can think of is a true hack, and you'd be entering into a unchartered territory. But, it may be worth a try.
    First, you need to create a subclass of oracle.jbo.server.ViewObjectImpl in the oracle.jbo.server package. This is because you need to override one of the package private methods. Suppose you define oracle.jbo.server.TempBaseViewObjectImpl which extends ViewObjectImpl.
    Override the following method:
    int[] getDeleteParticipants()
    This method returns an array of EO bases for which ViewRow's delete should cause deletion of EntityRow's.
    So, before you remove a ViewRow, you should set some flag in your TempBaseViewObjectImpl, so that getDeleteParticipants() would return "new int[0];" This will cause no EntityRow's to be deleted. Only the ViewRow will be removed from the collection.
    Note that you should reset this flag after the operation, so that you can delete the EntityRow's (when necessary).
    Your real VO should then subclass TempBaseViewObjectImpl.
    Once we fix this problem and provide a real API, you should remove TempBaseViewObjectImpl and extend your real VO from ViewObjectImpl instead of TempBaseViewObjectImpl.
    Thanks.
    Sung

  • How to update duplicate row from table

    Hi,
    how to update duplicate row from table?
    First to find duplicate row then update duplicate row with no to that duplicate row in oracle.
    can you give me suggestion on it?
    Thanks in advance.
    your early response is appreciated...

    In order to find a duplicate row, see:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1224636375004
    (or search this forum, your question has been asked before)
    In order to update it, just create and use an Oracle sequence, have it start and increment at a value that doesn't exist in your table.
    If that doesn't get you going, post some CREATE TABLE + INSERT INTO statements, and the results you want from them, in other words: a complete testcase.

  • How do I remove duplicate contacts from my  contacts

    How do I remove duplicate contacts from my  contacts

    This is usually the result of syncing between icloud and itunes, stop syncing contacts through one of them.
    iCloud: Resolving duplicate Contacts after setting up iCloud Contacts
    In some cases, data can appear to be duplicated, but actually your client application or device stored your data in multiple locations or data stores.Instead of attempting to remove or edit duplicate Contacts , you should verify if and how your Contacts are duplicated .
    http://support.apple.com/kb/TS4147

  • Removing duplicate values from selectOneChoice bound to List Iterator

    I'm trying to remove duplicate values from a selectOneChoice that i have. The component binds back to a List Iterator on the pageDefinition.
    I have a table on a JSF page with 5 columns; the table is bound to a method iterator on the pageDef. Then above the table, there are 5 separate selectOneChoice components each one of which is bound to the result set of the table's iterator. So this means that each selectOneChoice only contains vales corresponding to the columns in the table which it represents.
    The selectOneChoice components are part of a search facility and allow the user to select values from them and restrict the results that are returned. The concept is fine and i works. However if i have repeating values in the selectOneChoice (which is inevitable given its bound to the table column result set), then i need to remove them. I can remove null values or empty strings using expression language in the rendered attribute as shown:
    <af:forEach var="item"
    items="#{bindings.XXXX.items}">
    <af:selectItem label="#{item.label}" value="#{item.label}"
    rendered="#{item.label != ''}"/>
    </af:forEach>
    But i dont know how i can remove duplicate values easily. I know i can programatically do it in a backing bean etc.... but i want to know if there is perhaps some EL that might do it or another setting that ADF gives which can overcome this.
    Any help would be appreciated.
    Kind Regards

    Hi,
    It'll be little difficult removing duplicates and keeping the context as it is with exixting standard functions. Removing duplicates irrespective of context changes, we can do with available functions. Please try with this UDF code which may help you...
    source>sort>UDF-->Target
    execution type of UDF is Allvalues of a context.
    public void UDF(String[] var1, ResultList result, Container container) throws StreamTransformationException{
    ArrayList aList = new ArrayList();
    aList.add(var1(0));
    result.addValue(var1(0));
    for(int i=1; i<var1.length; i++){
    if(aList.contains(var1(i)))
         continue;
    else{
    aList.add(var1(i));
    result.addValue(var1(i));
    Regards,
    Priyanka

Maybe you are looking for

  • How to get all songs to show up between computers in home sharing?

    I have a laptop that has all of my 1000+ iTunes songs downloaded from the iStore and CDs. I downloaded iTunes on my desktop and connected them with Home Sharing. At first iI thought it worked great but noticed less than half of my songs showed up in

  • HT201406 My touch pad is now in the centre of the screen?

    I am unable to see what I am writing as my touch pad as moved to the centre of the screen.

  • Saving keys in java

    Hi, i have the following problem: i want to save the generated keypair(RSA/DSA/X509) so that i can use it again later. I have to use Base64 for RSA/DSA. unfortunatly there was little info on the web about those problems (generating keys is good expla

  • Can't get my old mbox 1 to work with logic pro.

    i recently just got a quiksilver g4 to use for my home studio. i have logic pro, but i'm still saving up for a new interface. in the mean time i need to use my mbox1. i can't find the install disks for the drivers anwhere. does anyone know where i ca

  • Use connect to record video??

    I want to try to use connect to record video of an instructor to include in an online coures. I can record myself as the presenter, but I want to know if I can use it to record video of a participant? I looked in the documentation but couldn't find a