Eliminate duplicate values in a column

I have a table with following data
Dat id name
24-sep-2008 1 a
24-sep-2008 2 b
25-sep-2008 3 c
25-sep-2008 4 d
I want fetch only unique dat feild .
ex:
the result of the query im only expecting
24-sep-2008
25-sep-2008

I want fetch only unique dat feild . you have answer in your question itself :-)
How about some reading on the document.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10002.htm#SQLRF01702

Similar Messages

  • Finding duplicate values in a column with different values in a different c

    I'm finding duplicate values in a column of my table:
    select ba.CLAIM_NUMBER from bsi_auto_vw ba
    group by ba.CLAIM_NUMBER
    having count(*) > 1;
    How can I modify this query to find duplicate values in that column where I DON'T have duplicate values in a different specific column in that table (the column CLMT_NO in my case can't have duplicates.)?

    Well, you can use analytics assuming you don't mind full scanning the table.....
    select
       count(owner) over (partition by object_type),    
       count(object_type) over (partition by owner)
    from all_objects;You just need to intelligently (i didn't here) find your "window" (partition clause) to sort the data over, then make use of that (the analytics would be in a nested SQL and you'd then evaluate it in outside).
    Should be applicable if i understand what you're after.
    If you post some sample data we can mock up a SQL statement for you (if what i tried to convey wasn't understandable).

  • How find out the duplicate value from each columns.

    I have below four columns,
    How can i find out the duplicate value from each columns.
    with All_files as (
    select '1000' as INVOICE,'2000' AS DELIVERYNOTE,'3000' CANDELINVOICE,'4000' CANDELIVERYNOTE from dual union all
    select '5000','6000','7000','8000' from dual union all
    select '9000','1000','1100','1200' from dual union all
    select '1200','3400','6700','8790' from dual union all
    select '1000','2000','3000','9000' from dual union all
    select '1230','2340','3450','4560' from dual
    SELECT * FROM All_files
    Output should be as per below.
    1000 2000 3000 4000
    9000 1000 1100 1200
    1200 3400 6700 8790
    1000 2000 3000 9000
    Required to check uniqueness in cross columns.
    Thanks.

    Try this (sorry about the formatting)...
    WITH all_files AS (SELECT   '1000' AS INVOICE,
                                '2000' AS DELIVERYNOTE,
                                '3000' CANDELINVOICE,
                                '4000' CANDELIVERYNOTE
                         FROM   DUAL
                       UNION ALL
                       SELECT   '5000',
                                '6000',
                                '7000',
                                '8000'
                         FROM   DUAL
                       UNION ALL
                       SELECT   '9000',
                                '1000',
                                '1100',
                                '1200'
                         FROM   DUAL
                       UNION ALL
                       SELECT   '1200',
                                '3400',
                                '6700',
                                '8790'
                         FROM   DUAL
                       UNION ALL
                       SELECT   '1000',
                                '2000',
                                '3000',
                                '9000'
                         FROM   DUAL
                       UNION ALL
                       SELECT   '1230',
                                '2340',
                                '3450',
                                '4560'
                         FROM   DUAL),
        t_base
           AS (SELECT      invoice
                        || ','
                        || deliverynote
                        || ','
                        || candelinvoice
                        || ','
                        || candeliverynote
                           str
                 FROM   all_files),
        t_str
           AS (SELECT   str || ',' AS str,
                        (LENGTH (str) - LENGTH (REPLACE (str, ','))) + 1
                           AS no_of_elements
                 FROM   t_base),
        t_n_rows
           AS (    SELECT   LEVEL AS i
                     FROM   DUAL
               CONNECT BY   LEVEL <=
                               (    SELECT   SUM (no_of_elements) FROM t_str)),
        t_build AS (SELECT   t_str.str,
                             nt.i AS element_no,
                             INSTR (t_str.str,
                                    DECODE (nt.i, 1, 0, 1),
                                    DECODE (nt.i, 1, 1, nt.i - 1))
                             + 1
                                AS start_pos,
                             INSTR (t_str.str,
                                    1,
                                    DECODE (nt.i, 1, 1, nt.i))
                                AS next_pos
                      FROM      t_str
                             JOIN
                                t_n_rows nt
                             ON nt.i <= t_str.no_of_elements),
        t_build2
           AS (SELECT   RTRIM (str, ',') AS original_string,
                        SUBSTR (str, start_pos, (next_pos - start_pos))
                           AS single_element,
                        element_no
                 FROM   t_build),
        t_build3
           AS (SELECT   single_element,
                        COUNT( * )
                           OVER (PARTITION BY single_element
                                 ORDER BY single_element)
                           ele_count
                 FROM   t_build2)
    SELECT   DISTINCT INVOICE,
                      DELIVERYNOTE,
                      CANDELINVOICE,
                      CANDELIVERYNOTE
      FROM   all_files, t_build3
    WHERE   ele_count > 1
             AND (   INVOICE = single_element
                  OR DELIVERYNOTE = single_element
                  OR CANDELINVOICE = single_element
                  OR CANDELIVERYNOTE = single_element)I think this will be faster than the previous solution?
    Cheers
    Ben
    Edited by: Munky on Feb 17, 2011 2:11 PM - "I think this will be faster than the previous solution?", nope - it's not :(

  • How to delete duplicate values in a column?

    consider a table contains 2 columns(NAME & DEPARTMENT)
    NAME DEPARTMENT
    santhosh finance
    santhosh marketing
    rahul sales
    stephen IT
    stephen sales
    In the above table how to delete only the duplicate values(santhosh,stephen) in the column?

    If you don't care??
    delete emp
      where 1 < (select row_number() over(partition by deptno order by 1) from emp)
    Error at line 1
    ORA-01427: single-row subquery returns more than one rowI'd use something like
    delete emp e1
    where exists
             (select null
                from (select deptno, rowid rid, row_number () over (partition by deptno order by 1) rn from emp) e2
              where e1.rowid = e2.rid
                 and  1 < rn)

  • How to test if there are duplicate values in a column using PL/SQL

    Hello,
    I want to be able to test if there are duplicate values (VARCHAR2) in a particular column of the database using PL/SQL.
    Thanks
    Douglas

    If I have understood your requirement, then you are asking for a query like following.
    Select column_name from Tbl_name
    group by column_name
    having count(*) > 1;

  • How to remove all duplicate values from a column

    For some reason when a user is adding a record, it duplicates it three times. Why is that happening?
    Since there is many how can I remove any records that contains a duplicate in a specific column?

    Is this happening for all lists in site collection or this is the only one?
    Check on the list if there is any workflow attached. If yes then open the workflow in designer and check its logic it might be written to copy list items.
    Investigate if there is an event receiver deployed in your site where it creates duplicate entries. There has to be some custom code running which is causing this duplication otherwise out of the box behavior of lists is never like this.
    Please remember to click 'Mark as Answer'
    if the reply answers your query or 'Upvote' if it helps you.

  • How to restrict the duplicate values in lov column of VO based Adv Table

    Hi Gurus,
    I want to restrict the duplicate values at lov which is a colunm in an Adv Table.
    If user enters duplicate values then first it should show an error msg that Duplicate values have been entered.
    After the duplicate values have been removed, then the user can save all the values in the table.
    My Adv Table is based on a VO.
    The link how to restrict the duplicate values at form level
    talks about Adv Table based on a EoVO, which doesnot work in my case.
    My Approach,
    I am iterating through RowSetIterator and committing through PROCEDURE.
    I am able to avoid duplicate entry through a function checkRespId. (given below)
    Below code is for iterating and committing.
    public void saveline(String reqid,String userid)
    System.out.println("RequestId/saveline"+reqid);
    System.out.println("UserId/saveline"+userid);
    OAViewObject vo = (OAViewObject)getRespLineVO1();
    RespLineVORowImpl row = null;
    int fetchedRowCount = vo.getFetchedRowCount();
    RowSetIterator deleteIter = vo.createRowSetIterator("deleteIter");
    if (fetchedRowCount > 0)
    deleteIter.setRangeStart(0);
    deleteIter.setRangeSize(fetchedRowCount);
    for (int i = 0; i < fetchedRowCount; i++)
    System.out.println("Inside the for LOOP");
    row = (RespLineVORowImpl)deleteIter.getRowAtRangeIndex(i);
    String respoidid = row.getAttribute("ResponsibilityId")+"";
    String respname = row.getAttribute("ResponsibilityName")+"";
    String stdate = row.getAttribute("StartDate")+"";
    String enddate = row.getAttribute("EndDate")+"";
    String linestatus ="A";
    if(userid!=null)
    if(!(respoidid.equals("null")) && respoidid!=null)
    String checkingrespid=null;
    checkingrespid = checkRespId(userid,respoidid);+contains no if not duplicate and yes if its duplicate+
    System.out.println("checkingrespid for Resp with ID :"+respoidid+"exists or not "+checkingrespid);
    if(checkingrespid.equals("No"))
         String message, result = null;
    Connection txn = getOADBTransaction().getJdbcConnection();
    try
    calling PROC ...
    catch(Exception e)
    message = "Error in Inserting into line" + e;
    throw new OAException(message, OAException.ERROR);
    else
    throw new OAException("You have entered duplicate no. of values", OAException.ERROR);
    else
    System.out.println("respoidid is null");
    break;
    deleteIter.closeRowSetIterator();
    public String checkRespId(String userid,String respoidid)
    String createRow="No";
    OAViewObject vo = (OAViewObject)findViewObject("CheckRespVO1");
    if (vo != null)
    vo.setWhereClauseParams(null);
    vo.setWhereClauseParam(0, userid);
    vo.setWhereClauseParam(1, respoidid);
    vo.executeQuery();
    System.out.println("ROW COUNT IS "+vo.getRowCount());
    if(vo.getRowCount()>0)
    createRow="Yes";
    else
    createRow="No";
    return createRow;
    Problem:
    I remove the duplicate entries and click on save and get this error.
    Unable to perform transaction on the record. \nCause: The record contains stale data. The record has been modified by another user.
    \nAction: Cancel the transaction and re-query the record to get the new data.
    Thanks,
    Sombit

    Hi Anil,
    I am trying out your code but stuck in inserting the rows
    using your code in URL: http://oracleanil.blogspot.com/2010/09/oaf-passing-table-type-object-to-oracle.html
    I am always getting the same exception i.e COde blast in when I run.
    My modified code is:
    String[] as = null;
    Number[] vNumber = null;
    Number[] vNumberrespid = null;
    Number reqidnumber = null;
    reqidnumber = new Number(Integer.parseInt(reqid));
    Connection txn = getOADBTransaction().getJdbcConnection();
    String mCreateSearchRequestStatement = null;
    OAViewObject vo = (OAViewObject)findViewObject("RespLineVO1");
    int j = vo.getFetchedRowCount();
    try
    System.out.println("abouce try");
    vo.reset();
    if (vo.getFetchedRowCount() > 0)
    System.out.println(String.valueOf("Fetched row count ").concat(String.valueOf(vo.getFetchedRowCount())));
    int i = 0;
    as = new String[j];
    vNumber = new Number[j];
    vNumberrespid = new Number[j];
    while (vo.hasNext())
    vo.next();
    System.out.println(String.valueOf("Inisde the do while loop").concat(String.valueOf(i)));
    vNumber[i] = (reqidnumber);
    vNumberrespid = ((Number)vo.getCurrentRow().getAttribute("ResponsibilityId"));
    as[i] = String.valueOf(vo.getCurrentRow().getAttribute("ResponsibilityName")).concat(String.valueOf(""));
    System.out.println("Request ID "+reqidnumber[i]);//getting null even there is some value selected
    System.out.println("ResponsibilityId "+vNumberrespid[i]);//getting null even there is some value selected
    System.out.println("Resp Name "+as[i] );//getting null even there is some value selected
    i++;
    CallableStatement cs = txn.prepareCall("{call XX_PassTableType.XX_PassTableType_prc(:1, :2,:3)}");
    ARRAY array = new ARRAY(new ArrayDescriptor("APPS.JTF_NUMBER_TABLE", txn), txn, vNumber);
    ARRAY arraynew = new ARRAY(new ArrayDescriptor("APPS.JTF_NUMBER_TABLE", txn), txn, vNumberrespid);
    ARRAY array1 = new ARRAY(new ArrayDescriptor("APPS.JTF_VARCHAR2_TABLE_100", txn), txn, as);
    cs.setArray(1, array);
    cs.setArray(2, arraynew);
    cs.setArray(3, array1);
    cs.registerOutParameter(3, 2003, "JTF_VARCHAR2_TABLE_100");
    cs.execute();
    ARRAY error = null;
    error = (ARRAY)cs.getArray(2);
    if ((error != null) && (error.length() > 0))
    System.out.println(String.valueOf("Error is ").concat(String.valueOf(error.getArray())));
    String[] retError = new String[j];
    retError = (String[])error.getArray();
    System.out.println(String.valueOf("Error in saving data").concat(String.valueOf(retError[0])));
    cs.close();
    catch (Exception exception)
    throw new OAException("code blast", OAException.ERROR);
    Thanks,
    Sombit

  • Find duplication values from multiple columns in a big table

    Hi All,
    I am working on a 11gR2 database in linux. i want to display record that have duplicate values in 2 columns.
    1. Table Structure :-
    CREATE TABLE A
    ID NUMBER(10),
    F_NAME VARCHAR2(100 BYTE),
    L_NAME VARCHAR2(100 BYTE)
    2. Sample Data:-
    Insert into A
    (ID, F_NAME, L_NAME) Values (1,'TONY' ,'SUMIT');
    Insert into A
    (ID, F_NAME, L_NAME) Values (2,'SUMIT' ,'KEITH');
    Insert into A
    (ID, F_NAME, L_NAME) Values (3,'NORA','SMITH');
    Insert into A
    (ID, F_NAME, L_NAME) Values (4,'APRIL','TONY');
    Insert into A
    (ID, F_NAME, L_NAME) Values (5,'ROSS','TAM');
    ID F_NAME L_NAME
    1 TONY SUMIT
    2 SUMIT KEITH
    3 NORA SMITH
    4 APRIL TONY
    5 ROSS TAM
    4. My requirement is i need display IDs that it's F_NAME or L_NAME has duplication in F_NAME or L_NAME columns.
    The result should be
    ID
    1 reason: F_NAME (TONY) equals to L_NAME of record 4, L_NAME (SUMIT) equals to F_NAME of record 2
    2 reason: F_NAME (SUMIT) equals to L_NAME of record 1
    4 reason: L_NAME (TONY) equals to F_NAME of record 1
    record 3, 5 aren't in the result because there is no duplication in F_NAME or L_NAME columns for NORA,SMITH, ROSS, TAM
    The table contains 10 million records, i really need to consider the performance.
    kindly suggest me the solution

    Note: Forum members please suggest better approach to this -- below.. convert into SQL :)
    I know I will be opposed by many people in this forum for posting such in-efficient solution.
    But trying to learn along with you.. its an interesting problem which must deal with all rows vs all rows to get all combinations.
    But I am still thinking how to write it in SQL, probably will learn from this post after we receive some good SQL solution for the code what I am currently doing now.
    step 1: created a table B similar to table A and added a column reason
    CREATE TABLE B
      ID      NUMBER(10),
      F_NAME  VARCHAR2(100 BYTE),
      L_NAME  VARCHAR2(100 BYTE),
      REASON  VARCHAR2(1000 BYTE)  --- ADDED THIS
    )Definetely inefficient :(
    BEGIN
       FOR rec_outer IN (SELECT * FROM A) LOOP
          FOR rec_inner IN (SELECT * FROM A) LOOP
             IF (rec_outer.f_name = rec_inner.l_name) THEN
                UPDATE B
                   SET reason =
                             rec_outer.id
                          || ' reason: F_NAME ('
                          || rec_outer.f_name
                          || ') equals to L_NAME of record '
                          || rec_inner.id
                 WHERE b.id = rec_outer.id;
             END IF;
          END LOOP;
          FOR rec_inner IN (SELECT * FROM A) LOOP
             IF (rec_outer.l_name = rec_inner.f_name) THEN
                UPDATE B
                   SET reason =
                          reason
                          || CASE
                                WHEN reason IS NULL THEN
                                   rec_outer.id || ' reason: '
                                ELSE
                             END
                          || 'L_NAME ('
                          || rec_inner.f_name
                          || ') equals to F_NAME of record '
                          || rec_inner.id
                 WHERE b.id = rec_outer.id;
             END IF;
          END LOOP;
       END LOOP;
       COMMIT;
    EXCEPTION
       WHEN OTHERS THEN
          rollback;
          RAISE;
    END;OUTPUT:
    ID     F_NAME     L_NAME     REASON
    1     TONY     SUMIT     1 reason: F_NAME (TONY) equals to L_NAME of record 4,L_NAME (SUMIT) equals to F_NAME of record 2
    2     SUMIT     KEITH     2 reason: F_NAME (SUMIT) equals to L_NAME of record 1
    3     NORA     SMITH     
    4     APRIL     TONY     4 reason: L_NAME (TONY) equals to F_NAME of record 1
    5     ROSS     TAM     Cheers,
    Manik.
    Edited : Added rollback

  • Duplicate value in export file

    Hi,
    I have a sql report where I have implemented download to excel using the print attribute. When I export the report into Excel, there are few columns whose values getting duplicated in the spreadsheet where as those column values are blank in the report.
    for example.
    Query:
    select col1 col2 col3 col4 from table1;
    The report displays the correct value for col1 col2 col3 col4 but in the export file value for col1, col2, col3 are correct but col4 is picking up the value of col3.
    Any help? Thanks.
    --Manish                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi Scott,
    Could you please have a look at it.
    http://apex.oracle.com/pls/otn/f?p=47427:12
    When you will click download_excel at the bottom of the page, the export file will show you the duplicate values for the column [G-L].
    Thanks again for your help.
    --Manish
    Message was edited by:
    Manish Jha

  • 3.1 EA3 - Column value filter dropdown returns duplicate values

    Hello,
    SQL Developer 3.1 EA3 introduces a regression: the column value filter in the table data editor dropdown (filter column) now shows duplicate values. Previous versions (at least 3.0) returned unique values to select from.
    Since this is EA3 and not yet production, should I file a bug for this?
    Best Regards and many thanks for this tool,
    Olivier.
    Edited by: user9378013 on Jan 9, 2012 1:08 PM

    Yes it's a regression. Fixed it recently. In the next released build it should work properly.
    -Raghu

  • Duplicate Value comming while filter the Calculate Column in Sharepoint 2013 custom list. Thanks in advance

    

    Hi SanjayPradhan,
    Based on your formula, I could reproduce this issue in my SharePoint 2013 without any CUs.
    Then I created a new column using other types not Date&Time, add the formula =IF(ISBLANK([New Column]),"Employee","ExEmployee"), there is no duplicate values when filtering the calculated column. It seems that this issue only
    happens when judging Date&Time column in a calculated column.
    I tested in my SharePoint Online, and found I could not reproduce this issue on SharePoint Online.
    So, for your issue, please check whether you install any CUs 
    for your SharePoint 2013. And please install the latest CU for SharePoint 2013.
    You can find the latest CU for SharePoint as the link:
    http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=346
    Best Regards,
    Wendy
    Wendy Li
    TechNet Community Support

  • Prevent duplicate value being entered into a column

    How do we prevent user to enter duplicate value into one of the column of a multiple record block before we commit the form ?
    Can anybody help ?
    Thanks,
    Shu Wen

    Do you want the duplicate to be detected as soon as the item is validated ?
    If so, the only way I have found to do so is to maintain a copy of the contents of the block in a record group. Rather cumbersome and a few triggers needed, but I have one application where I had to do it. I have always found it restrictive that you cannot read values from other records without navigating to them. If anyone has found a better method I would be interested to hear.

  • How to raise an error message when duplicate value is entered in a tabular field column? Basically not allow duplicate value at the form level.

    Hi all,
    I have created a form with one data block MATURED_FD_DTL which looks like below:
    ACCT_FD_NO
    CUST_CODE
    FD_AMT
    FD_INT_BAL
    TDS
    CHQ_NO
    ADD_FD_AMT
    P_SAP_CODE
    P_TYPE
    CREATE TABLE MATURED_FD_DTL
      ACCT_FD_NO    VARCHAR2(17 BYTE)               NOT NULL,
      CUST_CODE     NUMBER(9),
      FD_AMT        NUMBER(15),
      FD_INT_BAL    NUMBER(15),
      TDS           NUMBER(15),
      CHQ_NO        NUMBER(10),
      ADD_FD_AMT    NUMBER(15),
      P_SAP_CODE    NUMBER(10),
      P_TYPE        VARCHAR2(1 BYTE)
    For MATURED_FD_DT.ACCT_FD_NO, Trigger: KEY_NEXT_ITEM, I have written the following code:
    DECLARE
    V1 NUMBER;
    V2 NUMBER;
    BEGIN
    V1:=:MATURED_FD_DTL.ACCT_FD_NO;
    MESSAGE('V1:'||V1);
    MESSAGE(' ');
    END;
         GO_ITEM('MATURED_FD_DTL.CUST_CODE');
    This is just a dummy code.
    When ever i enter the value in the field of ACCT_FD_NO, it pops up a message saying "V1:Value of ACCT_FD_NO",
    So i want to store that value .
    Compare them & if it is egual, it should pop up a message saying duplicate value is entered and must not allow to enter, at form_level.
    So how can I compare the ACCT_FD_NO value between FIRST_RECORD and NEXT_RECORD ??
    Help Me .
    Thank You.
    Oracle Forms 6i.
    Oracle 9i.

    Thank You HamidHelal.
    Actually before posting the code, I went through the first link you have mentioned. I tried also, it is quite tedious procedure, however i dint get the proper result, may be i have done some mistake. Anyways , can you tell me how do i check in database table, if a value exists OR IF VALUE FOUND & then message and raise form trigger failure; something like below.
    IF :MATURED_FD_DTL.ACCT_FD_NO EXISTS
    THEN MESSAGE('YOU HAVE ENTERED AN EXISTING OR DUPLICATE VALUE');
              MESSAGE(' ');
    RAISE FORM_TRIGGER_FAILURE;
    END;
    OR
    IF :MATURED_FD_DTL.ACCT_FD_NO FOUND
    THEN MESSAGE('YOU HAVE ENTERED AN EXISTING OR DUPLICATE VALUE');
              MESSAGE(' ');
    RAISE FORM_TRIGGER_FAILURE;
    END;
    Is there any equivalent in the form in oracle forms 6i?? Please let me know how do i do this??

  • How to eliminate duplicates from multiple subscriptions in iCal?

    Is there a way to eliminate duplicate entries created when subscribing to multiple calendars?  As an example - I have a subscription with each of my kids school calendars (one is in middle school the other elementary). I end up with several duplicates such as the following: 
    February 14, 2014
    * Valentines Day (calendar)
    * Valentines Day (elementary)
    * Valentines Day (middle school)
    Thanks for your help!
    -Curt

    Your specification can be interpreted more than one way.
    In the examples you give, "duplicate records" not only have the same EMPNO, but all the data is the same. If this is what you are trying to avoid, use DISTINCT. Instead ofFROM EMP_TEST Ewrite FROM (select distinct * from EMP_TEST) EThis will eliminate duplicates if and only if every column has the same value.
    Again, not sure if this is what you want but it would work for your sample data.
    P.S. I agree with sb92075, you should make EMPNO a primary key and avoid the problem altogether.

  • Eliminate duplicates in subseries

    Hi,
    I am looking for a better solution for my problem. I've already solved it by pipeline function and just wonder if there is another (faster or more sophisticated) way.
    Source (subquery) provides record by record in certain order. I want to eliminate record if some fields are equal to relevant fields in previous record(s).
    Example data:
    with
      source as (select 1 rn , 'a' a, 'a' b, 10 c from dual union all
                 select 2, 'a', 'a', 10 from dual union all
                 select 3, 'a', 'b', 10 from dual union all
                 select 4, 'a', 'b', 10 from dual union all
                 select 5, 'a', 'b', 10 from dual union all
                 select 6, 'c', 'd', 10 from dual union all
                 select 7, 'c', 'd', 10 from dual union all
                 select 8, 'a', 'a', 10 from dual union all
                 select 9, 'a', 'a', 10 from dual)
    select * from source;
            RN A B          C
             1 a a         10
             2 a a         10
             3 a b         10
             4 a b         10
             5 a b         10
             6 c d         10
             7 c d         10
             8 a a         10
             9 a a         10Query should eliminate
    - record rn=2 because columns A and B are the same in rn=1 (previous record)
    - record rn=4 and rn=5 because columns A and B are the same in record rn=3 (previous and previous' previous)
    - record rn=7 because columns A and B are the same in rn=6 (previous record)
    - record rn=9 because columns A and B are the same in rn=8 (previous record)
    Record rn=8 shouldn't be eliminated because previous record is different in A and B.
    Another words I want to achieve first occurence in subseries of same records.
    Additional info: Column C is constant for all records. Real source produces a few thousand records with many 'duplicates' (~99%)
    Desired output should be like that:
    '       RN A B          C
             1 a a         10
             3 a b         10
             6 c d         10
             8 a a         10Thanks in advance,
    Bartek

    Hi, Bartek,
    Yiou can do that with the analytic LAG function:
    with
      source as (select 1 rn , 'a' a, 'a' b, 10 c from dual union all
                 select 2, 'a', 'a', 10 from dual union all
                 select 3, 'a', 'b', 10 from dual union all
                 select 4, 'a', 'b', 10 from dual union all
                 select 5, 'a', 'b', 10 from dual union all
                 select 6, 'c', 'd', 10 from dual union all
                 select 7, 'c', 'd', 10 from dual union all
                 select 8, 'a', 'a', 10 from dual union all
                 select 9, 'a', 'a', 10 from dual)
    ,       got_dif         AS
         SELECT     rn, a, b c
         ,     CASE
                   WHEN  a = LAG (a) OVER ( PARTITION BY  c
                                                    ORDER BY      rn
                   AND   b = LAG (b) OVER ( PARTITION BY  c
                                                    ORDER BY      rn
                   THEN  0
                   ELSE  1
              END     AS dif
         FROM     source
    SELECT     rn, a, b c
    FROM     got_dif
    WHERE     dif     = 1;This assumes that each value of c is a world unto itself: only rows with the same value iof c will be compared to one another. If that's not what you want, just remove "PARTITION BY c" from both analytic clauses.
    Thanks for posting the sample data in such a convenient way! That's very helpful.
    Edited by: Frank Kulash on Jul 14, 2009 3:35 PM
    This solution is pretty close to Sanjay's solution.
    Sanjay used only one test in the CASE expression:
    case when lag(a||b) over ( order by rn) = a||b then 1 else 0 end  grp but that assumes that you never have, for example
    a='X' and b='YZ" on one row, and
    a='XY' and b='Z' on the next.
    Even though these two rows are different in both a and b, the concatenation of a||b ('XYZ') is the same. Sanjay's solution will only display the first row; the solution above will display both rows.

Maybe you are looking for

  • Catch Selection in JFileChooser without using Buttons

    How do you catch a selection in a JFileChooser without using the OK Button? If someone clicks on a file(and does not hit enter/cancel buttons), I want to get the file name. I tried actionevent but it only works after the user hits a button.

  • Rescursive Include

    Hi all, I am using Tomcat 3.1. I have a main JSP page that uses the include tag to include a second jsp page. In the main jsp page I have a form whose action is to post to the main page. However, because of the include tag I keep getting the error: o

  • JAVA-XML Please Help

    Hello All, I'm somewhat new to Java and XML and I'm having this problem: I have an program that does an HTTP Post and gets back an XML response. I'm trying to parse the response. I'm completely lost I think, and I apologize for my utter stupidity or

  • Aptana - Can coldfusion builder be installed into aptana?

    Can coldfusion builder be installed into aptana?  Has anyone attempted this?  I currently have sites that have a mix of php and cfml files and would like to be able to use a single ide for all.  just curious thank you c

  • FTP directory with AIR?

    How do you read an FTP directory with AIR?