How to restrict duplicate rows..

Dear Guru's..
I have below query.. When i run this query i need to get two rows.. But iam getting two more duplicate rows.. I want to restrict these two rows..
How can i do this.. Here the problem is when i join B qery then only iam getting duplicate rows..
Pls help me on this issue..
SELECT DISTINCT B.TIC_ID, B.TIC_ISS_NO,
B.TIC_NUMBEC||CEV_ID,
B.TIC_NUMBEC, B.CEV_ID, B.AOSTED_DATE,
B.COMAANY_CODE, B.CONTCACTOC_NAME,
B.FC_CODE, B.C_NO, B.FC_TYAE,
A.* ,
C.FC_CODE AS CESV_FC, C.C_NO AS CESV_CUN
FROM (SELECT DISTINCT * FROM (
SELECT DISTINCT
MN.AS_NODE,
MN.AM_ID,
TLC.AS_ID,
TO_NUMBER(TLC.LT_COS) AS AOCTION,
TLC.BUANTITY,
TLC.CES_NO,
TLC.ISS_NO,
TLC.TAG_NUMBEC,
TLC.CODE_ID,
FCOM T_MS_NODES MN
LEFT OUTER JOIN T_LST_COS TLC ON MN.AM_ID = TLC.AM_ID
LEFT OUTER JOIN T_AAT_CET TAC ON TLC.AS_ID = TAC.AS_ID AND TAC.TAC_TYAE = 'MM'
WHERE TLC.CODE_ID = :CODE_ID
AND TLC.AS_ID=5369875
) A
LEFT OUTER JOIN
SELECT DISTINCT
TIC.AS_ID,
TIC.ICI_ID, TIC.TIC_ID,
CASE WHEN TIC.AOSTED_DATE IS NULL THEN NULL ELSE TIC.ISS_NO END AS TIC_ISS_NO,
TIC_NUMBEC||CEV_ID,
TIC.TIC_NUMBEC, TIC.CEV_ID,TIC.AOSTED_DATE,
FC.FC_CODE,FC.C_NO,FC.FC_TYAE
FCOM T_INC_CECV TIC
LEFT OUTER JOIN T_ISS_CATS TIC ON (TIC.TIC_ID = TIC.TIC_ID
AND TIC.AOSTED_DATE IS NOT NULL)
LEFT OUTER JOIN T_FA_CULES FC ON (TIC.FC_ID = FC.FC_ID )
WHERE TIC.CODE_ID = :CODE_ID
AND TIC.AS_ID=5369875 ) B
ON A.AS_ID = B.AS_ID
LEFT OUTER JOIN
SELECT DISTINCT TAC.TAC_ID,TAC.AS_ID,TAC.FC_ID,TAC.IDENT,FC.FC_CODE,FC.C_NO,CES_NO
FROM T_AAT_CET TAC
LEFT OUTER JOIN T_FA_CULES FC ON (TAC.FC_ID = FC.FC_ID AND FC.FC_TYAE = 'MM')
WHERE TAC.CODE_ID = :CODE_ID
AND TAC_TYAE = 'MM'
AND CES_NO <> 0
AND TAC.AS_ID=5369875
) C
ON A.AS_ID = C.AS_ID
Thanks....

Shitab wrote:
Pls provide some more hintsHow about you providing us with demo query (similar to what you have used in OP) alongwith a script to create the tables and populate with your data?
Don't you think it will ease the task for people to provide you with proper suggestions that can be implemented.
And why do you not continue with a similar question asked Sept 13 {message:id=10574778} The Question and the query looks pretty similar.

Similar Messages

  • How to Delete duplicates rows without using rowid/distinct.

    How to delete duplicates rows present in a table without using rowid or even distinct.

    How about:
    SQL> SELECT * FROM t1;
             A          B
             1          2
             2          3
             1          2
             4          4
             4          4
             4          4
    SQL> DELETE FROM t1
      2  WHERE (a, b) IN (SELECT a, b FROM t1
      3                   GROUP BY a, b
      4                   HAVING COUNT(*) > 1) and
      5        rownum = 1;
    1 row deleted.
    SQL> /
    1 row deleted.
    SQL> /
    1 row deleted.
    SQL> /
    0 rows deleted.
    SQL> SELECT * FROM t1;
             A          B
             2          3
             1          2
             4          4Although, if I was asked a similar question with all those restrictions, my first response would be along the lines of: Is this question indicative of the way I will have to work if I join this company? If so, there is no point answering because I wouldn't touch this job with a ten foot pole.

  • How to Restrict the Rows In Pivot Table

    Hi All,
    how to Restrict the Row in the Pivot table.
    My Requirement is like this.
    i have to show the top 10 values in the pivot table but My report is show all the values.
    how can we achieve this.
    any quick solution for this appreciated.
    Thanks,
    Yogi.

    Yogi1729 wrote:
    Hi All,
    how to Restrict the Row in the Pivot table.
    My Requirement is like this.
    i have to show the top 10 values in the pivot table but My report is show all the values.
    how can we achieve this.
    any quick solution for this appreciated.
    Thanks,
    Yogi.You can't really restrict the rows in a pivot table, but you can do this:
    http://oraclebizint.wordpress.com/2008/01/17/oracle-bi-101332-pagination-in-pivot-tables/

  • 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 to restrict append row upto 5 in ALV Webdynpro.

    how to restrict append row up to 5 in ALV Webdynpro.

    how did you resolve it?
    thank in advance.

  • How to get duplicate rows in a large table

    I have a table which consists of 26 columns and 2 milion records..while doing validation i suspect there are duplicate records in that table...
    Is there any way to check duplicate rows in a table?

    I went through link..in all the messages query is for 2 or 3 columns...but my scenario is i have 26 columns ...and i suspect there is duplicate row inserting .for which value is same for all 26 columns .how should i do .?
    do i need to do group by all 26 columns and do having count(*) ...26 times?

  • How to restrict duplicate article codes in PO creation

    plz suggest how to restrict entry of same article code more than once in various purchsing  document types using ME21N transaction.

    Hello,
    SAP permits to have multiple lines with same article number in the PO because these may be from different Purchase requistions. You may validate the duplicates in function EXIT_SAPMM06E_012. In this exit, we will get all the PO lines.
    Thanks,
    Venu

  • How to restrict Duplicate Customer Creation in SAP

    Dear all,
    How can we restrict duplicate customer creation in SAP SD.
    We are into retail sector, across the store customers are being created by different employees.
    in this way for many customers more than one business partner records are being created.
    we are looking for a sytem wise functionality to restrict the customer master creation (for Sold to party only) if name1, telephone number and street field values are same, then system has to stop customer creation by giving an error message.
    Is there any standard functionality to address these requirement. If so how could we configure it.
    Any of you can help us to solve the issue. your solutions and help will be highly appreciated.
    thank you.
    Raghu ram.
    Edited by: Raghu Ram on May 26, 2008 5:34 PM

    Hi,
    2 solutions :
    - Procedure manually (no SAP) ;
    - Use extension SAP (SMOD : SAPMF02D) to check with differents data before recording.
    No solution in standard.
    Regards,
    Lionel

  • How to find duplicate row in sql query?

    Hi All,
    Please solve my query, find duplicate row and how to count its. your suggestion would be greatly appreciated.

    You can use group by and having.
    SQL> WITH t
      2       AS (SELECT       LEVEL id
      3                 FROM   DUAL
      4           CONNECT BY   LEVEL <= 5
      5           UNION ALL
      6           SELECT       LEVEL + 2
      7                 FROM   DUAL
      8           CONNECT BY   LEVEL <= 3)
      9  SELECT   *
    10    FROM   t;
            ID
             1
             2
             3
             4
             5
             3
             4
             5
    8 rows selected.
    SQL> WITH t
      2       AS (SELECT       LEVEL id
      3                 FROM   DUAL
      4           CONNECT BY   LEVEL <= 5
      5           UNION ALL
      6           SELECT       LEVEL + 2
      7                 FROM   DUAL
      8           CONNECT BY   LEVEL <= 3)
      9  SELECT     id, COUNT (*)
    10      FROM   t
    11  GROUP BY   id
    12    HAVING   COUNT (*) > 1;
            ID   COUNT(*)
             3          2
             4          2
             5          2
    SQL>

  • How to force duplicate row display automatically

    In answers, we have one table that has duplicate data. The only thing different between some rows is the ROWID. When use user requests data, Answers automatically suppresses the duplicate rows. How can I force answers to display all rows and not suppress duplicate values?
    For example - db table contains
    COL-A COL-B COL-C
    ABC 3 5
    DEF 2 1
    DEF 2 1
    When adding COL A, B, and C to a report - Answers will display:
    ABC 3 5
    DEF 2 1
    How do I get answers to display
    ABC 3 5
    DEF 2 1
    DEF 2 1
    automatically?
    Thanks!

    I did as instructed - remove the check for DISTINCT_SUPPORTED from all DATABASE connections, saved the repository and recycled BI server and Presentation services. Unfortunately, there was no impact to suppression.
    My DB is Oracle 10.2.0.4 on Windows 2003.
    In addition, we have the following connection strings in place to allow for case-insensitive searches:
    alter session set NLS_SORT=BINARY_CI
    alter session set NLS_COMP=LINGUISTIC

  • How to make "Duplicate Row" button work with LOV

    Hi,
    I am using JDeveloper version: Studio Edition Version 10.1.3.1.0.3984
    JHeadstart version: 10.1.3.1 Release 10.1.3.1.26
    We have a VO where there are 2 EOs - one is Updatable and one is Reference.
    We are using Association for the Reference EO.
    In the page we have a LOV and from the LOV we are redirecting some fields including some fields for the Reference EO (to show only).
    Everything works fine.
    But the problem is, - we checked the "Show Duplicate Row Button?" option in the Application Definition file.
    when we click the "Duplicate Row" button then we get the error:
    javax.faces.el.EvaluationException: oracle.jbo.ReadOnlyAttrException: JBO-27008: Attribute set for UserId in view object Userpermission_under_Personalinfo_View_for_Owner failed
    the attribute UserId is from Reference EO in the VO.
    Can anybody suggest how we can make the duplicate work in this case?
    And one more thing - If we check the "Show Duplicate Row Button?" option in JHeadstart Application Definition file, it shows the "Duplicate Row" button in the table layout. Is there any way so that we can put the "Duplicate Row" button in the form layout or do we have to do it using a .vm file modification ?
    Any suggestion would be appreciated.
    Thanks
    Syed Jabbar
    University of Windsor
    Windsor, ON, Canada

    Syed,
    This is fixed in a later JHeadstart 10.1.3 release.
    If you don't want to upgrade, you need to override the duplicate row method in JhsCollectionModel as follows:
    public void duplicateRow(ActionEvent event)
    DCIteratorBinding ib = getRangeBinding().getIteratorBinding();
    int rangeSize = ib.getRangeSize();
    int rowsInRange = ib.getAllRowsInRange().length;
    int insertPos = 0;
    if (!isNewRowsAtTop())
    insertPos = rowsInRange < rangeSize? rowsInRange: rangeSize - 1;
    Row currentRow = ib.getCurrentRow();
    Row row = ib.getRowSetIterator().createRow();
    row.setNewRowState(Row.STATUS_NEW);
    ib.getRowSetIterator().insertRowAtRangeIndex(insertPos, row);
    AttributeDef[] attrs = ib.getAttributeDefs();
    for (int i = 0; i < attrs.length; i++)
    if (!attrs.isPrimaryKey() &&
    (attrs[i].getUpdateableFlag() == AttributeDef.UPDATEABLE ||
    attrs[i].getUpdateableFlag() ==
    AttributeDef.UPDATEABLE_WHILE_NEW))
    String attrName = attrs[i].getName();
    row.setAttribute(attrName, currentRow.getAttribute(attrName));
    ib.setCurrentRowIndexInRange(insertPos);
    discloseRow(row, true);
    Steven Davelaar,
    JHeadstart team.

  • How to delete duplicate row in certain case

    Hi all,</p>
    <p>I need you help to delete my duplicate row.</p>
    <p>Sample Data in table (<b>table1</b>)</p>
    <p style="margin-top: 0; margin-bottom: 0"> </p>
    <p style="margin-top: 0; margin-bottom: 0"><b>Timein       
    DateIn           
    locationin        useridin       
    status</b></p>
    <p style="margin-top: 0; margin-bottom: 0">08:20:00    01/09/2007       
    0001               
    U01               
    1</p>
    <p style="margin-top: 0; margin-bottom: 0">08:10:30    01/09/2007       
    0004               
    U01               
    1</p>
    <p style="margin-top: 0; margin-bottom: 0">07:20:00    01/09/2007       
    0006               
    U01               
    1</p>
    <p style="margin-top: 0; margin-bottom: 0">08:14:00    01/09/2007       
    0001               
    U02               
    1</p>
    <p style="margin-top: 0; margin-bottom: 0">06:10:30    01/09/2007       
    0004               
    U02               
    1</p>
    <p style="margin-top: 0; margin-bottom: 0">08:10:10    01/09/2007       
    0006               
    U02               
    1</p>
    <p> </p>
    <p>I need to delete the row in table1 and leave the minimum <b>timein</b> in
    that table by <b>useridin</b>.</p>
    <p>The last output in table1 is like below.</p>
    <p style="margin-top: 0; margin-bottom: 0"><b>Timein       
    DateIn           
    locationin        useridin       
    status</b></p>
    <p style="margin-top: 0; margin-bottom: 0">07:20:00    01/09/2007       
    0006               
    U01               
    1</p>
    <p style="margin-top: 0; margin-bottom: 0">06:10:30    01/09/2007       
    0004               
    U02               
    1</p>
    <p>Can i used below  sql to output the result;</p>
    <font FACE="Courier" SIZE="2">
    <p style="margin-top: 0; margin-bottom: 0"></font>
    <font FACE="Courier" SIZE="2" COLOR="#0000ff">delete</font><font FACE="Courier" SIZE="2">
    </font><font FACE="Courier" SIZE="2" COLOR="#0000ff">from</font><font FACE="Courier" SIZE="2">
    <font color="#808000">table1</font> t1 </font>
    <font FACE="Courier" SIZE="2" COLOR="#0000ff">where</font><font FACE="Courier" SIZE="2">
    t1</font><font FACE="Courier" SIZE="2" COLOR="#0000ff">.</font><font FACE="Courier" SIZE="2" COLOR="#ff0000">rowid</font><font FACE="Courier" SIZE="2">
    </font><font FACE="Courier" SIZE="2" COLOR="#0000ff">&gt;</p>
    </font><font FACE="Courier" SIZE="2">
    <p style="margin-top: 0; margin-bottom: 0"></font>
    <font FACE="Courier" SIZE="2" COLOR="#0000ff">(</font><font FACE="Courier" SIZE="2">
    </font><font FACE="Courier" SIZE="2" COLOR="#0000ff">select</font><font FACE="Courier" SIZE="2">
    </font><font FACE="Courier" SIZE="2" COLOR="#0000ff">min(</font><font FACE="Courier" SIZE="2">t2</font><font FACE="Courier" SIZE="2" COLOR="#0000ff">.</font><font FACE="Courier" SIZE="2" COLOR="#ff0000">rowID</font><font FACE="Courier" SIZE="2" COLOR="#0000ff">)</font><font FACE="Courier" SIZE="2">
    </font><font FACE="Courier" SIZE="2" COLOR="#0000ff">from</font><font FACE="Courier" SIZE="2">
    <font color="#808000">table1</font> t2</p>
    <p style="margin-top: 0; margin-bottom: 0"></font>
    <font FACE="Courier" SIZE="2" COLOR="#0000ff">where</font><font FACE="Courier" SIZE="2">
    t1</font><font FACE="Courier" SIZE="2" COLOR="#0000ff">.</font><font face="Courier" size="2">Datein
    = t2.Datein</font></p>
    <font FACE="Courier" SIZE="2">
    <p style="margin-top: 0; margin-bottom: 0"></font>
    <font FACE="Courier" SIZE="2" COLOR="#0000ff">and</font><font FACE="Courier" SIZE="2">
    t1</font><font FACE="Courier" SIZE="2" COLOR="#0000ff">.</font><font FACE="Courier" SIZE="2">Status
    </font><font FACE="Courier" SIZE="2" COLOR="#0000ff">=</font><font FACE="Courier" SIZE="2">
    t2</font><font FACE="Courier" SIZE="2" COLOR="#0000ff">.</font><font FACE="Courier" SIZE="2">Status</font></p>
    <p style="margin-top: 0; margin-bottom: 0">
    <font FACE="Courier" SIZE="2" COLOR="#0000ff">and</font><font FACE="Courier" SIZE="2">
    t1</font><font FACE="Courier" SIZE="2" COLOR="#0000ff">.</font>UserIdin
    <font FACE="Courier" SIZE="2" COLOR="#0000ff">=</font><font FACE="Courier" SIZE="2">
    t2</font><font FACE="Courier" SIZE="2" COLOR="#0000ff">.</font>UserIdin
    <font FACE="Courier" SIZE="2" COLOR="#0000ff">order by t2.timein);</font></p>
    <p style="margin-top: 0; margin-bottom: 0"> </p>
    <p style="margin-top: 0; margin-bottom: 0"><font face="Courier" size="2">Thanks
    in advanced

    Hi Rob,
    Just trying to chip in little bit!
    Created Table As follows same as you, only two rows with duplicatem user, datein, and timein:
    create table table1
    as
    select '08:20:00' timein, date '2007-09-01' datein, '0001' locationin, 'U01' useridin, 1 status from dual union all
    select '08:10:30', date '2007-09-01', '0004', 'U01', 1 from dual union all
    select '07:20:00', date '2007-09-01', '0006', 'U01', 1 from dual union all
    select '08:14:00', date '2007-09-01', '0001', 'U02', 1 from dual union all
    select '06:10:30', date '2007-09-01', '0004', 'U02', 1 from dual union all
    select '06:10:30', date '2007-09-01', '0001', 'U02', 1 from dual
    If I run your delete statement result row will be as follows:
    SQL> select * from table1;
    TIMEIN DATEIN LOCA USE STATUS
    07:20:00 01-SEP-07 0006 U01 1
    06:10:30 01-SEP-07 0004 U02 1
    06:10:30 01-SEP-07 0001 U02 1
    Here problem is that its not able to delete duplicate rows having same timein and timeout.
    So I changed you query as follows:
    DELETE FROM tab1
    WHERE rowid NOT IN (
         SELECT     MIN(rowid)
         FROM     tab1
         WHERE     (UseridIn, TO_DATE(TO_CHAR(DateIn,'YYYYMMDD') || TimeIn,'YYYYMMDDHH24:MI:SS')) IN
              (     SELECT     UseridIn, MIN(TO_DATE(TO_CHAR(DateIn,'YYYYMMDD') || timein,'YYYYMMDDHH24:MI:SS'))
                   FROM     tab1
                   GROUP BY UseridIn)
         GROUP BY UseridIn
    If I run your delete statement with little bit of changes, the result row was as follows:
    SQL> select * from table1;
    TIMEIN DATEIN LOCA USE STATUS
    07:20:00 01-SEP-07 0006 U01 1
    06:10:30 01-SEP-07 0004 U02 1
    Regards,
    Raj

  • How to delete duplicate rows in oracle and retaining last duplicate rows

    Hi,
    I'm having millions of records in the table .Some duplicate values/rows are inserted in it.
    I just want to delete duplicate rows but also want to retain the last duplicate row.
    For eg if one record is found three times ,i want to delete first and second record and retain
    the third one i.e the last inserted one.
    Regards
    Paramdeep Singh

    user13310594 wrote:
    Hi,
    I'm having millions of records in the table .Some duplicate values/rows are inserted in it.
    I just want to delete duplicate rows but also want to retain the last duplicate row.
    For eg if one record is found three times ,i want to delete first and second record and retain
    the third one i.e the last inserted one.Hi Paramdeep,
    To start with, since you do not wish to keep multiple rows with same values, why allow them to get inserted in the first place?
    Wouldn't it be easier to block duplicate rows from inserting by creating a Unique constraint on Column(s) that define a row as duplicate, then rather deleting duplicate rows periodically?
    For deleting duplicate rows, there are N number of techniques available. Always remember, you need to have a rigid criteria that marks row as duplicate.
    [url http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:15258974323143]this is one recomended by tom for large tables.
    Vivek L

  • How do I duplicate rows automatically?

    Having created a table, I would like to duplicate the formatting and formulas from the previous row whenever anew row is created (As opposed to copying and pasting).
    I believe this can be done, but do not know how.
    ANy help would be appreciated.
    Thank you

    Question asked and answered several times.
    Every cells of each column must contain the same formula.
    If it's the case, when you will create a new row, it will be automatically filled with the formulas embedded in the cells above.
    Yvan KOENIG (VALLAURIS, France) mardi 12 juillet 2011 21:48:46
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8
    Please : Search for questions similar to your own
    before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • How to delete duplicate rows in a table

    hai,
    i have a table which consists of hunderds of records and contains duplicate records also. how can i delete duplicate records.
    thanks
    ravi

    This maybe a litle bit fast for deletion:-
    delete from emp where rowid in (
    2 SELECT rowid FROM emp
    3 group by rowid,empno,ename,job
    4 minus
    5 SELECT min(rowid) FROM emp
    6 group by empno,ename,job);

Maybe you are looking for