Query displaying duplicate records

I have written a query to display  materials having no purchasing group.
Can any one plz tell me that why it is displaying duplicate results.
Thanks
aprr

Apprr,
You have given us no information to help you.
Please list the Datasource:  Table Join, Direct Read, Logical database, or program.
Please list any Table or Tables you are using.
If you are using Table join(s), please list the joined tables and all linking fields.
Rgds,
DB49

Similar Messages

  • Select query-using Union All display duplicate records.

    Hello All Gurus-
    I am using Oracle 9.i
    When i use the following query to fetch the records based on BUILDNUMBERNAME and ASSIGNED_BUILD then i am getting duplicate records -
    select T1.ID FROM Defect T1,statedef T2,repoproject T3
    WHERE T1.STATE=T2.ID AND T1.repoproject = T3.dbid AND T3.name Like 'ABC' AND T1. ASSIGNED_BUILD like '1.4.5.6'
    Union All
    select T1.ID FROM Defect T1,statedef T2,repoproject T3
    WHERE T1.STATE=T2.ID AND T1.repoproject = T3.dbid AND T3.name Like 'ABC' AND T1.BUILDNUMBERNAME like '1.4.5.6'
    How can i use the order by on T1.ID ? When i use the Order by T1.ID then it throws some error.
    Kindly help me in this :(
    Thanks in advance.

    Sorry for not providing all of the details -
    I am using Toad tool to run the query.
    1-When i use the following query -
    Select T1.ID FROM Defect T1,statedef T2,repoproject T3
    WHERE T1.STATE=T2.ID AND T1.repoproject = T3.dbid AND T3.name Like 'ABC' AND T1. ASSIGNED_BUILD like '1.4.5.6' order by T1.ID
    Union All
    select T1.ID FROM Defect T1,statedef T2,repoproject T3
    WHERE T1.STATE=T2.ID AND T1.repoproject = T3.dbid AND T3.name Like 'ABC' AND T1.BUILDNUMBERNAME like '1.4.5.6' order by T1.ID
    ORA-00933: SQL command not properly ended.
    2-If i am not using the T1.ID and run the following query
    Select T1.ID FROM Defect T1,statedef T2,repoproject T3
    WHERE T1.STATE=T2.ID AND T1.repoproject = T3.dbid AND T3.name Like 'ABC' AND T1. ASSIGNED_BUILD like '1.4.5.6'
    Union All
    select T1.ID FROM Defect T1,statedef T2,repoproject T3
    WHERE T1.STATE=T2.ID AND T1.repoproject = T3.dbid AND T3.name Like 'ABC' AND T1.BUILDNUMBERNAME like '1.4.5.6'
    Then it is running fine but it is displaying the duplicate values like -
    00089646
    00087780
    00089148
    00090118
    00090410
    00088503
    00080985
    00084526
    00087108
    00087109
    00087117
    00088778
    00086714
    00079518
    00087780
    00089148
    00090392
    00090393
    00090395
    00090398
    00090401
    00090402
    00090403
    00090406
    00090408
    00088503
    00080985
    00084526
    00087108
    00087109
    00087117
    00088778
    00086714
    00079518

  • Need a query for duplicate records deletion

    here is one scenario...
    23130 ----> 'A'
    23130 ----> 'X'
    23130 ----> 'c'
    These are duplicate records.. when we remove duplicates, the record must get 'c', if it contains A,C,X. If it contains A and X, then the record must get 'X'. That means the priority goes like this C-->X-->A. for this i need query.. this is one scenario. It would be great if u reply me asap.

    Hello
    It's great that you gave examples of your data, but it is quite helpful to supply create table and insert statements too along with a clear example of expected results. Anyway, I think this does what you are looking for.
    CREATE TABLE dt_dup (ID NUMBER, flag VARCHAR2(1))
    INSERT INTO dt_dup VALUES(23130, 'A');
    insert into dt_dup values(23130, 'X');
    insert into dt_dup values(23130, 'C');
    INSERT INTO dt_dup VALUES(23131, 'A');
    INSERT INTO dt_dup VALUES(23131, 'X');
    DELETE
    FROM
      dt_dup
    WHERE
      ROWID IN (  SELECT
                    rid
                  FROM
                    (   SELECT
                          rowid rid,
                          ROW_NUMBER() OVER (PARTITION BY ID ORDER BY CASE
                                                                        WHEN flag = 'A' THEN
                                                                          3
                                                                        WHEN flag = 'X' THEN
                                                                          2
                                                                        WHEN flag = 'C' THEN
                                                                          1
                                                                      END
                                            ) rn
                        FROM
                          dt_dup
                  WHERE
                    rn > 1
    select * from dt_dup;HTH
    David
    Edited by: Bravid on Jun 30, 2011 8:12 AM

  • Display duplicate records

    Hi,
    I want to make a report which shows duplicate records in a table. We can fetch the duplicate records by using the rowid in sql but how to make it work in OBIEE? the table does not hold a unique key.

    try something similar http://carpediemconsulting.wordpress.com/2008/08/13/displaying-duplicate-values-in-obiee-reports/
    OR
    Use Direct Database Request to write direct SQLs as you do in Database

  • Query creating duplicate records

    Hi
    I need to create a report that gives the po number, po line item number, material number and the delivery post code.
    I have created a query with the following tables:
    EKKO, EKPO, EBAN, VBEP, VBAK, VBPA, ADRC.
    I have deleted the wrong link between EKKO and EKPO and retained all other links as suggested.
    Could anybody let me know why there are duplicate records in the report pls?
    Thanks
    Desp09

    Desp09 wrote:
    Hi
    >
    > I have connected
    >
    > EKKO-EBELN to EKPO
    >
    >  EKPO -EBELN and EKPO-EBELP  to the same of EBAN
    >
    > also EKPO-BANFN and EKPO-BNFPO to the same of EBAN
    >
    > EBAN-BANFN and EBAN-BNFPO to VBEP
    >
    > VBEP-VBELN to VBAK-VBELn
    >
    > VBAK-VBELN to VBPA-VBELN
    >
    > VBPA-ADRNR to ADRC-ADDRNUMBER.
    >
    > This is the first time I have created a query so if you can kindly explain the logic of the error it would help in my future reports.
    >
    > Thanks
    > Priya
    Hi Priya,
    You can simplify the process if you make use of the LDB, which will fetch the same report with std LDB available in the system.
    You can define multiple infosets and  pull the fields for easier approach.
    Regards
    Shiva

  • How to tune the query for duplicate records while joining the two tables

    hi,i am executing the query which has retrieving multiple tables,in which one of them has duplicate record,how to get single record

    Not enough info...subject says "tune" the query, message says "write" the query...and where is actual query that you had tried ?

  • Af:query : Delete duplicate records from results manually

    Hi
    I have an ADF page with af:quey on a view object.  I have created a viewcriteria to choose few attributes from the view object.
    The view object is created manually using a sql query, where the query has joins to various other tables (it has outer joins too).
    On submit, due to one to many relationship in the joins, i am getting duplicate rows in the results.
    I am currently using 11.1.1.7.0 jDeveloper (We can't upgrade to upper versions due to other constraints of the project).  I thought the property 'Selected in Query = false' on the view object attribute would fix this problem (to eliminate duplicate rows).  But, i guess, 11.1.1.7.0 don't seem to be supporting this option.
    Hence, i was thinking of manually deleting the duplicates from the results of the af:query before displaying it to the user.
    Please let me know, if there is a better way to solve the problem, if not, how can i manually remove duplicates from the resultset before displaying the results.
    I created a new QueryLIstener method to delete the duplicates, by executing the view object, but it retruns all the records without applying the criteria.  May be i am doing something wrong.
    Please suggest the best way.
    Thanks
    Pradeep

    Hi Frank,
    I do have a distinct in my sql but due to 1->M joins i get duplicate rows.  I can avoid it only if i can unselect the attributes in the select.
    I like to display the attributes to the user to choose the criteria (which adds as a predicate to the sql).  But I would like to unselect the 1-M attributes from the results, so i get distinct rows as i have mentioned distinct in the sql.
    Is there a way to restrict duplicate rows ?
    Thanks
    Pradeep

  • Avoid displaying duplicates records?

    I have the following query to display records from two tables:
    select * from COLLATERAL CL, COLLATERAL_REF CF where CF.ACCOUNT_NUMBER like '1000000001%' AND CF.COLLATERAL_ID=CL.COLLATERAL_ID
    How do i change this query to avoid duplicate collateral_id's?.
    Collateral_id is the primary key on Collateral table and foreign key on Collateral_ref table.
    null

    Thanks isotope for your reply.
    I just ran the query and I get 00904:"cl"."collateral_id": invalid identifier.
    Here is my table structure:
    Collateral (Collateral_id is Primary Key):
    Collateral_id Collateral_type Description Serial_Number ..
    1 Title 97 Accord 111111
    32 Mortgage 122 Grand Av
    26 Title          2008 BMW 222222
    Collateral_Ref (Collateral_id is foreign key)
    Collateral_id Account_Number      Description ..
    1          100000001 111111111     97 Accord     
    1          100000001 222222222     97 Accord     
    32          100000001 444444444     122 Grand Av
    32          100000001 333333333     122 Grand Av
    32          100000001 999999999     122 Grand Av
    26          200000001 222222222 2008 BMW
    So, My query currently returns all the duplicate (1 twice and 32 thrice)
    expected results should be:
    Collateral_id Collateral_type Description ..
    1 Title 97 Accord
    32 Mortgage 122 Grand Av

  • QUERY - No Duplicate records from 2nd table ???

    Hi Experts,
    I really need help with this. I have 2 tables A and B. See below
    <b>A -
         B</b>
    X -
         XB1
    XB2
    XB3
    Y----
    YB
    Z----
    ZB
    I select a record from A and get its record from B and give it on the output. For entry X I have 3 records in Table B. I want the output to give only 1 record from B for X. It can be any record. How can this be achieved in Query ?
    Is there a special Join ? or can this be achieved by coding in Query ? If so how ?
    I really appreciate your help.
    Thanks !!

    First get the data from table A.
    select * from table (A) into table i_a.
    loop at i_a.
    select single * from table B into table i_b.
    move b reord to final internal table
    append final internal table.
    endloop.

  • ABAP Query Shows duplicate records

    Hi
    I have a ABAP query which links the VIQMEL table(notifcation number) and the VBAK table(order & net value).  The report outputs as:
    Notification A   Order 10   SO value 1000
    Notification B   Order 10   SO value 1000
    Notification C   Order 10   SO value 1000
    Notification D   Order 10   SO value 1000
    The problem is the value is repeated 4 times when we only want it shown the once, is this possible to do and if so how can this be done?
    thanks
    Joe

    Desp09 wrote:
    Hi
    >
    > I have connected
    >
    > EKKO-EBELN to EKPO
    >
    >  EKPO -EBELN and EKPO-EBELP  to the same of EBAN
    >
    > also EKPO-BANFN and EKPO-BNFPO to the same of EBAN
    >
    > EBAN-BANFN and EBAN-BNFPO to VBEP
    >
    > VBEP-VBELN to VBAK-VBELn
    >
    > VBAK-VBELN to VBPA-VBELN
    >
    > VBPA-ADRNR to ADRC-ADDRNUMBER.
    >
    > This is the first time I have created a query so if you can kindly explain the logic of the error it would help in my future reports.
    >
    > Thanks
    > Priya
    Hi Priya,
    You can simplify the process if you make use of the LDB, which will fetch the same report with std LDB available in the system.
    You can define multiple infosets and  pull the fields for easier approach.
    Regards
    Shiva

  • Query - Remove duplicate records based on value of  one field

    Hi,
    Pleae see the data below,
    how to remove records when its count 0
    AND those records (name ) repeat with count > 0
    existing data
    name                       loc                            count
    aaa          a1          10
    aaa          a1          0
    bbb          b1          0
    ccc          c1          0
    dcc          d1          11
    dcc          d1          0
    required output
    name                       loc                            count
    aaa          a1          10
    bbb          b1          0
    ccc          c1          0
    dcc          d1          11
    remove these records -
    aaa          a1          0
    dcc          d1          0Thanks.

    i assume that loc always corresponds to name. So to find the rows to remain is just a simple group by
    with data as(
    select 'aaa' name,'a1' loc,10 count from dual union all
    select 'aaa','a1',0 from dual union all
    select 'bbb','b1',0 from dual union all
    select 'ccc','c1',0 from dual union all
    select 'dcc','d1',11 from dual union all
    select 'dcc','d1',0 from dual )
    select
      name
    , loc
    , max(count) cnt
    from data
    group by
      name
    , loc
    order by
      name
    , loc
    NAME     LOC     CNT
    aaa     a1     10
    bbb     b1     0
    ccc     c1     0
    dcc     d1     11to find the other is just a minus
    with data as(
    select 'aaa' name,'a1' loc,10 count from dual union all
    select 'aaa','a1',0 from dual union all
    select 'bbb','b1',0 from dual union all
    select 'ccc','c1',0 from dual union all
    select 'dcc','d1',11 from dual union all
    select 'dcc','d1',0 from dual )
    select name,loc,count from data
    minus
    select
      name
    , loc
    , max(count) cnt
    from data
    group by
      name
    , loc
    order by
      name
    , loc
    NAME     LOC     COUNT
    aaa     a1     0
    dcc     d1     0so a delete would be
    delete from data
    where
    (name,loc,count)
    in
    (select name,loc,count from data
    minus ..regards

  • SAP query returning duplicate records

    Hi all,
    I'll try to elaborate as much as possible so here goes:
    I have a query that I am trying to run in SAP B1 8.8 which is not returning the true set of results I am expecting.
    Essentially I am trying to filter by product based on delivery notes. I have the query as follows -
    SELECT count(*), sum(T0.[DocTotal]-T0.[VatSum]) as "Order Value"
    FROM ODLN T0  INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode
    WHERE DateName(mm,T0.DocDate) = 'November'
    and DateName(yyyy,T0.DocDate) = '2011'
    and (T1.[GroupCode] = '102' or T1.[GroupCode] = '107')
    This returns the correct result of 1320 row numbers and the given sum.
    When I try to break this query down further by product using the query below, the values are doubled, tripled, quadrupled etc and summed up to give a number that is extremely high.
    The code is as follows:
    SELECT distinct count (*), sum(distinct T0.[DocTotal]-T0.[VatSum]) as "Order Value" from DLN1 T1
    inner join ODLN T0 on T0.DocEntry = T1.DocEntry
    Inner join OITM T2 on T2.ItemCode = T1.ItemCode
    inner join OCRD T3 on T0.CardCode = T3.CardCode
    WHERE DateName(mm,T0.DocDate) = 'November'
    and DateName(yyyy,T0.DocDate) = '2011'
    and (T3.[GroupCode] = '102' or T3.[GroupCode] = '107')
    and (T2.[ItmsGrpCod] = '108' or T2.[ItmsGrpCod] = '112' or T2.[ItmsGrpCod] = '115')
    This also returns 1819 rows where there should be less based on the product.
    Please let me know if I am not explaining myself well or need further clarification.
    Thanks!

    hi,
    try to run this code from your SQL management studio
    SELECT     SUM(T0.DocTotal - T0.VatSum) AS [Order Value], T0.DocTotal - T0.VatSum AS [Order Value], T0.DocNum, T0.DocDate, T0.CardCode, T0.CardName, T0.DocTotal,
                          T1.ItemCode, T1.Dscription, T1.Quantity, T2.GroupCode, T3.ItmsGrpCod
    FROM         ODLN AS T0 INNER JOIN
                          DLN1 AS T1 ON T0.DocEntry = T1.DocEntry INNER JOIN
                          OCRD AS T2 ON T0.CardCode = T2.CardCode INNER JOIN
                          OITM AS T3 ON T1.ItemCode = T3.ItemCode
    GROUP BY T0.DocTotal - T0.VatSum, T0.DocNum, T0.DocDate, T0.CardCode, T0.CardName, T0.DocTotal, T1.ItemCode, T1.Dscription, T1.Quantity, T2.GroupCode,
                          T3.ItmsGrpCod
    HAVING      (T2.GroupCode = 102 OR
                          T2.GroupCode = 107) AND (T3.ItmsGrpCod = 108 OR
                          T3.ItmsGrpCod = 112 OR
                          T3.ItmsGrpCod = 115) AND (T0.DocDate BETWEEN CONVERT(DATETIME, '2011-11-01 00:00:00', 102) AND CONVERT(DATETIME, '2011-11-17 00:00:00', 102))
    regards,
    Fidel

  • Counting duplicate records in a table

    Hi,
    I have to display duplicate records in a table,but the table name and column should be passed dynamically(In procedure). Please let me know the query for this.

    Try this one, is used to find the duplicate value from table
    Type: I
    SELECT * FROM employees e1 WHERE rowid> (SELECT min(rowid)
    FROM employees e2 WHERE e1.department_id=e2.department_id);
    Type: II
    SELECT * FROM my_table t1 WHERE EXISTS (SELECT 'x' FROM my_table t2
    WHERE t2.key_value1 = t1.key_value1
    AND t2.key_value2 = t1.key_value2
    AND t2.rowid > t1.rowid);
    Type: III
    SELECT count(*), empn FROM empmast_dum
    GROUP BY empn HAVING count(*) >1 ORDER BY empn;
    Type: IV
    SELECT dep, name,net,RANK() OVER (PARTITION BY dep ORDER BY net) rank
    FROM empmast_dump
    WHERE dep=04;
    Type: V
    SELECT empn FROM empmast_dump
    WHERE empn NOT IN(SELECT MIN(empn)
    FROM empmast_dump GROUP BY NAME;
    I have to display duplicate records in a
    table,but the table name and column should be passed
    dynamically(In procedure). Please let me know the
    query for this.When you need to pass table name dynamically in your procedure ,
    just enter table name as substitution variable or bind variable, if u want to know about
    this, read here
    venki
    http://venki-hb.blogspot.com/2008/02/basic-sql-query-tips.html

  • Duplicate records in a collection

    Hi Experts,
    Just now I've seen a thread related to finding duplicate records in a collection. I understand that it is not advisable to sort/filter data in a collection.
    (https://forums.oracle.com/thread/2584168)
    Just for curiosity I tried to display duplicate records in a collection. Please Please .. this is just for practice purpose only. Below is the rough code which I wrote.
    I'm aware of one way - can be handled effectively by passing data into a global temporary table and display the duplicate/unique records.
    Can you please let me know if there is any other efficient wayto do this.
    declare
      type emp_rec is record ( ename varchar2(40), empno number);
      l_emp_rec emp_rec; 
      type emp_tab is table of l_emp_rec%type index by binary_integer;
      l_emp_tab emp_tab;
      l_dup_tab emp_tab;
      l_cnt number;
      n number :=1;
    begin
    -- Assigning values to Associative array
      l_emp_tab(1).ename := 'suri';
      l_emp_tab(1).empno := 1;
      l_emp_tab(2).ename := 'surya';
      l_emp_tab(2).empno := 2;
      l_emp_tab(3).ename := 'suri';
      l_emp_tab(3).empno := 1;
    -- Comparing collection for duplicate records
    for i in l_emp_tab.first..l_emp_tab.last
    loop
        l_cnt :=0;  
    for j in l_emp_tab.first..l_emp_tab.last 
        loop      
           if l_emp_tab(i).empno  =  l_emp_tab(j).empno and l_emp_tab(i).ename  =  l_emp_tab(j).ename then
               l_cnt := l_cnt+1;          
                   if l_cnt >=2 then
                      l_dup_tab(n):= l_emp_tab(i);
                   end if;
           end if;                   
        end loop;  
    end loop;
    -- Displaying duplicate records
    for i in l_dup_tab.first..l_dup_tab.last
    loop
       dbms_output.put_line(l_dup_tab(i).ename||'  '||l_dup_tab(i).empno);
    end loop;
    end;
    Cheers,
    Suri

    Dunno if this is either easier or more efficient but it is different.  The biggest disadvantage to this technique is that you have extraneous database objects (a table) to keep track of.  The advantage is that you can use SQL to perform the difference checks easily.
    Create 2 global temporary tables with the structure you need, load them, and use set operators (UNION [ALL], INTERSECT, MINUS) to find the differences.  Or, create 1 GTT with an extra column identifying the set and use the extra column to identify the set records you need.

  • Using Rownum and ROwid returns duplicate records

    Hi All,
    We have implemented pagination as below using rowid and rownum
    SELECT
    id
    FROM
    emp
    WHERE
    ROWID IN
    SELECT RID FROM (SELECT
    ROWID RID,
    ROWNUM RNUM
    FROM
    SELECT ID FROM emp
    WHERE
    ((T_ID IN (200005,200229,200230,200249,200250,200049))) AND
    (dte >= sysdate-90) AND
    (LOWER(DESC) = LOWER ('A') AND
    LOWER(NVL(FLAG,'0')) != LOWER ('3') AND
    LOWER(MODDE) like LOWER ('%210%')) ORDER BY dte ASC ))
    WHERE ROWNUM < 11) WHERE RNUM>= 1)) ORDER BY dte emp.ASC
    But, we face that - the query inserts duplicate records in consecutive pages. For Eg:
    1.if a,b,c,d,e - is returned for first iteration, then for the next iteration - f,g,h,a,y is returned.
    Is it because that the Order by clause doesnt have a Unique key column.
    Please help. or suggest how to efficietly implement pagination without performance hit

    try distinct since you are using only one column it will eliminate any duplicates.
    SELECT distinct id
      FROM emp
    WHERE (ROWID IN ( SELECT RID
                         FROM (SELECT ROWID RID,ROWNUM RNUM
                                 FROM (SELECT ID
                                         FROM emp
                                        WHERE ((T_ID IN (200005,200229,200230,200249,200250,200049)))
                                          AND (dte >= sysdate-90)
                                          AND (LOWER(DESC) = LOWER ('A')
                                          AND LOWER(NVL(FLAG,'0')) != LOWER ('3')
                                          AND LOWER(MODDE) like LOWER ('%210%'))
                                       ORDER BY dte ASC ))
                                WHERE ROWNUM < 11) 
                        WHERE RNUM>= 1))
    ORDER BY dte emp.ASC

Maybe you are looking for

  • I can't update my itunes software.  I get an error.

    I can't update my

  • How to capture index/row no of row in table using object oriented alv.

    i have a table with many fields. i have an alv grid table displayed using object oriented alv. when i double click on a record, i call another screen. there i want to display the record number. eg, if i doubleclick on the third row, i will go to next

  • Java.io.notSerializableException:weblogic.jdbc.pool.Connection

    Hello,           In my servelts only sometime I get this exception. I am using WLS7.0 jDK           1.3.1(the one which comes with WLS7.0). I am using Java Beans which are all           serializable.(I have declared that the classes implements Serili

  • Oracle driver oci8&thin

    Hi, I need help with connectiong to oracle database. I connected to oracle database with thin driver, it worked fine. Than I wanted to connect without specifiing port. I used oci8. First I couldn't connect to database. then i found in some forum that

  • Recordstore- check existance of records without opening?

    Hello all This might be a really daft question but: Is is possible to check a the existance of records in a RecordStore without actually opening the Store? I would have thought not, but... I have just read that opening and closing RecordStores can ta