How to select  rows with duplicate column values

hi,
i have a table property_details which has these 2 columns customerno and propertyno a customer can have many properties and property number has to be unique. but somehow these property number has been duplicated at an earlier stage so i have for a customer with many properties the same property number
how i will select such records whose asset numbers are the same
for ex
customer no property no
a1300 1
a1300 1
a1300 1
a2330 10
a2330 10
a2330 10
kindly suggest me a solution

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>

Similar Messages

  • How  to identfy  rows  with  same  column value

    Hi
    I have a table student
    id ( pkey)
    name
    class
    marks
    i need to check the existence of duplicate values like
    say the values are :
    id name class marks
    1 alan 6 85
    2 victor 4 97
    3 alan 6 85
    i need to know if there is any matching row in the table --- like in this case id=1 and id=3 have same value for all the columns except for id .
    so the result shud tell me the ids which have duplicate values for name , class , marks and also those ids for which there is no duplicacy
    for id= 1 i see that id= 3 has same values
    and id=2 has no duplicates
    how do i show it ??
    The result i expect is
    name class marks count
    alan 6 85 2
    victor 4 97 1
    Message was edited by:
    SHUBH

    EMP
    id name class marks
    1 alan 6 85
    2 victor 4 97
    3 alan 6 85
    You can use a self join to pull out the data which are almost duplicate without a column values here in this example without id the first and third records are duplicate.
    select e.id,e.name,e.class,e.marks from EMP e,EMP d where e.name=d.ename and e.class=d.class and e.marks=d.marks and e.id<>d.id;

  • How to select rows with Empty Column Entry

    I am trying to select all rows with an empty column
    select row1 from table where row2=' ';
    Any suggestions. I tried a space and no space in between the ''.

    An (theoretical) argument could be made that an empty string is not NULL (uknown), however Oracle's SQL and PL/SQL engines make no such distinction for VARCHAR2 and CHAR data types. As stated, you must use NULL as the comparison.
    Michael

  • How to select 2column from 1 column values

    Hi All,
    How to select 2column from 1 column values
    Ex : In Emp they have JOB column
    JOB
    CLERK
    MANAGER
    SALESMAN
    MANAGER
    MANAGER
    ANALYST
    PRESIDENT
    SALESMAN
    CLERK
    CLERK
    ANALYST
    CLERK
    here i want to get output like as follows
    Ex: ejob1 ejob2
    ANALYST SALESMAN
    ANALYST SALESMAN
    Can anyone helps me in this,it is urget
    Thanks,

    Something like
    select a.job, b.job from scott.emp a, (select job from scott.emp) b
    CLERK     CLERK
    CLERK     SALESMAN
    CLERK     SALESMAN
    CLERK     MANAGER
    CLERK     SALESMAN
    CLERK     MANAGER
    CLERK     MANAGER
    CLERK     ANALYST
    CLERK     PRESIDENT
    CLERK     SALESMAN
    CLERK     CLERK
    CLERK     CLERK
    CLERK     ANALYST
    CLERK     CLERK
    SALESMAN     CLERK
    SALESMAN     SALESMAN
    SALESMAN     SALESMAN
    SALESMAN     MANAGER
    ...

  • How to repeat rows based on column value

    Hi all,
    I have a query that gives me a result with a column value for example 4.
    I now want to repeat this row 4 times with a new column that calculated from 1 - 4.
    Or when column value is 3 I want to repeat row 3 times with new column name 1-3
    Can anyone help me with this please? :)

    Hi Yvanlathem,
    To achieve your requirement, you can reference the recursive approach as below.
    DECLARE @T TABLE(Col1 CHAR(1),Col2 INT)
    INSERT INTO @T VALUES('A',1),('B',2),('C',3)
    ;WITH Cte([Char],[Repeat]) AS
    SELECT Col1,Col2 FROM @T
    UNION ALL
    SELECT [Char],[Repeat]-1 FROM Cte
    WHERE [Repeat]>1
    SELECT * FROM Cte ORDER BY [Char],[Repeat]
    OPTION(MAXRECURSION 0)
    /* Output
    Char Repeat
    A 1
    B 1
    B 2
    C 1
    C 2
    C 3
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • How to select rows whose one column contains some specific characters ?

    These is a table say T1 with a column say C1
    Let the field C1's values be:
    row 1)DE/SPT/A/FWD
    row 2)G/SPT/DE/DE/SPT
    row 3)R/FWD/SPT/A/FWD/FWD
    row 4)A/A/DE/SPT/FWD
    row 5)FWD/SPT/E/DE/A
    How to get only those rows whose C1 column contains FWD in last ?

    We can solve this with the simple use of a wildcard:
        select *
        from t1
        where c1 like '%FWD'
        /Note that this query will execute a full table scan, because any index you may have on C1 will be ignored: indexes are organised on the leading characters.
    cheers, APC

  • How to select each character of column value

    Hi All,
    How can i get each character separately of a column value in a select statement.
    LIKE i emp table if ename='Test' then i want
    a select statement that can give me the result like this
    T,e,s,t
    Regards,
    Anil R

    or this?
    SQL> create table mytable
      2  as
      3  select 'test' text from dual union all
      4  select 'a text, containing two comma''s (,)' from dual union all
      5  select 'a text ending with a comma,' from dual
      6  /
    Tabel is aangemaakt.
    SQL> select text
      2       , substr(regexp_replace(text,'(*?)',',\1'),2,length(text)*2-1) with_commas
      3    from mytable
      4  /
    TEXT                               WITH_COMMAS
    test                               t,e,s,t
    a text, containing two comma's (,) a, ,t,e,x,t,,, ,c,o,n,t,a,i,n,i,n,g, ,t,w,o, ,c,o,m,m,a,',s, ,(,,,)
    a text ending with a comma,        a, ,t,e,x,t, ,e,n,d,i,n,g, ,w,i,t,h, ,a, ,c,o,m,m,a,,
    3 rijen zijn geselecteerd.Regards,
    Rob.
    Message was edited by:
    Rob van Wijk
    Slight modification to cater for strings beginning and ending with commas.

  • How to select rows with min value on a specific column

    I have a query:
    select
      m.x1,
      round (to_date (l.y1, 'mm/dd/yyyy HH:MI:SS AM') - m.x2, 0) as numofdays
    from
      table1 m,
      table2 l
    where
      l.x3 = m.x3 and
      to_date (l.y1, 'mm/dd/yyyy HH:MI:SS AM') >= TO_DATE('01012013','MMDDYYYY') and
    and I got this result table:
    x1 (ID)
    numofdays
    001
    5
    001
    10
    002
    2
    003
    3
    003
    1
    004
    0
    005
    66
    several ID's have multiple values on the second column, I want to have only distinct IDs with smallest "numofdays" like this:
    x1 (ID)
    numofdays
    001
    5
    002
    2
    003
    1
    004
    0
    005
    66
    Any ideas?

    Hi,
    The most general and versatile way is a Top-N Query:
    WITH   got_r_num AS
        select
                m.x1,
                round (to_date (l.y1, 'mm/dd/yyyy HH:MI:SS AM') - m.x2, 0) as numofdays
        ,       ROW_NUMBER () OVER ( PARTITION BY  m.x1
                                     ORDER BY      to_date (l.y1, 'mm/dd/yyyy HH:MI:SS AM') - m.x2
                                   )  AS r_num
        from 
              table1 m,
              table2 l
        where
              l.x3 = m.x3 and
              to_date (l.y1, 'mm/dd/yyyy HH:MI:SS AM') >= TO_DATE('01012013','MMDDYYYY') and
    SELECT  x1, numofdays
    FROM    got_r_num
    WHERE   r_num   = 1
    If you'd care to post CREATE TABLE and INSERT statements for your sample data, then I could test it.
    Notice that the sub-query (got_r_num) is exactly what you posted, only with a new column (r_num) added to the SELECT clause.

  • How to get fourthly row (row4) first column value (col1) in matrix

    Hi to all,
    In FMS, how to get fourthly row (row4) first column value (col1) in matrix in document.
    select $[$38.1.4]
    But it display the first row
    Please give me hint.
    Thank you

    Hi Eric,
    FMS may only apply to current row.  There is no way to get any other fixed row.
    Thanks,
    Gordon

  • How to merge rows with similar values in alv grid display in webdynpro

    Hi experts,
                   i want to know about how to merge rows with similar values in alv grid display of webdynpro.grouping rows is possible in table display in webdynpro but i am not able to do row grouping in the alv grid display in webdynpro.
    kindly suggest.
    thanks ,
    Anita.

    Hi Anita,
    did you find a solution for this? I have opened a Thread, if you know the answer maybe you could help me out:
    Is there an ALV function similar to the TABLE Row grouping?
    Thanx in advanced!!!
    Kind Regards,
    Gerardo J

  • I have 105 rows with alternating columns of No. sold

    I have 105 rows with alternating columns of No. Sold and Amount Sold, for six different dates.  I want the two totals columns on the right to sum every other column for the Total No. Sold and the same but one over for Total Amount Sold.  I know how to do this for a single row, as I have done for the last totals row.  How could I do the formula for all rows without entering it for each one, or if that is not possible, maybe I could copy the formula in some way to make it easier?

    rogerfrombellingham wrote:
    ...  I know how to do this for a single row, as I have done for the last totals row.  How could I do the formula for all rows without entering it for each one, or if that is not possible, maybe I could copy the formula in some way to make it easier?
    Yes, Roger, you can easily copy those formulas for all the rest of the 105 rows.
    Select the two totals cells, click on the little circle in the lower right corner of the selection and drag it to the bottom.
    Jerry

  • OBIEE - How to selectively hide or disable columns on a dashboard prompt?

    Hello! I need some help with OBIEE dashboard Prompts. Any help will be highly appreciated!
    Question 1. How to selectively hide or disable columns on a dashboard prompt or the entire prompt? There seems to be no "hide" or "dsable" options on
    prompts.
    Question 2. How to synchronize 2 different prompts on the same dashboard?
    The application is this: There are total of 2 tabs on a dashboard ("tab_1" and "tab_2"). Each tab uses different prompts ("pr_1" and "pr_2"), having just one first drop down column in common ("Product_id").
    The desired functionality is this: user selects "Product_id" on the first tab's prompt, which filters its reports (on "Go") and also propagates to the second tab. When user clicks on the second tab, the reports there are already filtered (or begin filtering) by "product_id", selected on the first tab.
    Question 3. How to prevent the reports from retrieving when switching to a different tab on a dshboard? Specifying dummy default values in the prompt does
    not seem to preven reports from retrieving, which still takes time.
    Thank you very much!
    Roger

    Regarding Question 2:
    What you need to have is a Dashboard scope dashboard prompt for Product_ID (i.e., Don't use the column prompt from the prompt tab within the Request.)
    1) Create the dashboard prompt, put it on tab1 and save the prompt to a presentation variable, say prmtProdID. Set the scope to "dashboard." (This is the default, by the way.) If you create a dashboard prompt and set the scope to "dashboard," then the prompt values selected will hold true across dashboard pages.
    2) On tab2, go to your report and in Criteria mode, apply a filter to the Product_ID column making it equal to the PV. (Click the filter icon, Add>Variable>Presentation Variable and type prmtProdID. Save.)
    When the user selects a Product_ID on tab1 of your dashboard and hits "Go," not only will it filter your report on tab1, when you go to tab2 the report here will be filtered with the same value selected in the prompt on tab2.
    Regarding Question 3:
    If you implement 2, you cannot implement 3. You can't have it both ways. Not for the same scenario. But if you want to know how to do it in general, read this:
    http://obieeone.com/2009/08/24/how-to-stop-queries-to-automatically-fire-off-once-entering-dashboarddashboard-page/

  • Update rows with a column

    hi
    gurus
    updating a row with a column
    i have first table with 5 columns
    id telephone, telex, mobile,email,santige
    1 9123455 12 987 @ 12452
    i have another second table having a columns like
    id comm , commid
    1 3245 1
    1 23 2
    1 786 3
    1 we@ 4
    1 122 5
    the commid is
    1-telephone 2-telex,3-mobile,4-email,5--santige
    the problem is i want to update the second table with the data of first table
    final data will comes like this
    id comm , commid
    1 9123455 1
    1 12 2
    1 987 3
    1 @ 4
    1 12452 5
    please adjust the data below the columns (for view)

    Something like
    UPDATE table2 t2
       SET comm = (SELECT DECODE(t2.commid, 1, telephone,
                                            2, telex,
                                            3, mobile,
                                            4, email,
                                            5, santige)
                     FROM table1 t1
                    WHERE t1.id = t2.id)should work.
    CREATE TABLE table1 (
      id NUMBER,
      telephone VARCHAR2(100),
      telex     VARCHAR2(100),
      mobile    VARCHAR2(100),
      email     VARCHAR2(100),
      santige   VARCHAR2(100)
    CREATE TABLE table2 (
      id     NUMBER,
      comm   VARCHAR2(100),
      commid NUMBER
    INSERT INTO table1 VALUES( 1, 'telephone', 'telex', 'mobile', 'email', 'santige' );
    BEGIN
      INSERT INTO table2 VALUES( 1, 'x', 1 );
      INSERT INTO table2 VALUES( 1, 'x', 2 );
      INSERT INTO table2 VALUES( 1, 'x', 3 );
      INSERT INTO table2 VALUES( 1, 'x', 4 );
      INSERT INTO table2 VALUES( 1, 'x', 5 );
    END;
    UPDATE table2 t2
       SET comm = (SELECT DECODE(t2.commid, 1, telephone,
                                            2, telex,
                                            3, mobile,
                                            4, email,
                                            5, santige)
                     FROM table1 t1
                    WHERE t1.id = t2.id);
    SQL> SELECT * FROM table2;
            ID COMM                COMMID
             1 telephone                1
             1 telex                    2
             1 mobile                   3
             1 email                    4
             1 santige                  5Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to handle dbms_xmldom with no data values.(no_data_found error in dom)

    hi,
    i have below block,
    DECLARE
    doc dbms_xmldom.DOMDocument;
    node dbms_xmldom.DOMNode;
    elem dbms_xmldom.DOMElement;
    cur_node dbms_xmldom.DOMNode;
    root_elem_data dbms_xmldom.DOMElement;
    root_elem_tab dbms_xmldom.DOMElement;
    root_node_data dbms_xmldom.DOMNode;
    mode_elmn dbms_xmldom.DOMElement;
    mode_node dbms_xmldom.DOMNode;
    mode_text dbms_xmldom.DOMText;
    doc1 DBMS_XMLDOM.DOMDOCUMENT;
    root_node_data1 DBMS_XMLDOM.DOMNODE;
    child_document DBMS_XMLDOM.DOMDOCUMENT;
    child_rootnode DBMS_XMLDOM.DOMNODE;
    V_CLOB CLOB;
    v_doc CLOB;
    v_EMP CLOB;
    v_output_filename VARCHAR2(300) := 'SPOOL_DIR/'||'EMP_XML_FILE.xml';
    l_xmltype XMLTYPE;
    BEGIN
    doc := dbms_xmldom.newDOMDocument;
    node := dbms_xmldom.makeNode(doc);
    dbms_xmldom.setversion(doc, '1.0');
    dbms_xmldom.setCharset(doc, 'UTF8');
    elem := dbms_xmldom.createElement(doc, 'PartnerInfo');
    dbms_xmldom.setAttribute(elem,'xmlns','EMP');
    cur_node := dbms_xmldom.appendChild(node, dbms_xmldom.makeNode(elem));
    mode_elmn := dbms_xmldom.createElement(doc, 'EMPLOYEE');
    mode_node := dbms_xmldom.appendChild(cur_node,dbms_xmldom.makeNode(mode_elmn));
    BEGIN
    SELECT value(e) INTO l_xmltype
    FROM TABLE(XMLSequence(Cursor(SELECT * FROM EMP1 where EMPNO=7501))) e;
    child_document := DBMS_XMLDOM.newDOMDocument(l_xmltype);
    root_node_data1 := dbms_xmldom.importNode(doc,dbms_xmldom.makeNode(dbms_xmldom.getDocumentElement(child_document)),TRUE);
    root_node_data1 := DBMS_XMLDOM.appendChild(root_node_data, root_node_data1);
    EXCEPTION
    WHEN OTHERS THEN
    Dbms_Output.Put_Line('Error in SELECT stmt(UC_PARTNER_MS):::'||'error::'||SQLERRM);
    END;
    dbms_lob.createtemporary(v_doc, true);
    dbms_xmldom.writeToClob(doc,v_doc,'UTF8');
    v_EMP:= v_doc;
    dbms_xmldom.writeToFile(DOC,v_output_filename,'UTF8');
    dbms_xmldom.freeDocument(doc);
    --Dbms_Output.Put_Line('THE OUTPUT IS::'||V_EMP);
    EXCEPTION
    WHEN OTHERS THEN
    Dbms_Output.Put_Line('Error in SELECT stmt(UC_PARTNER_MS):::'||'error::'||SQLERRM);
    END;
    The xml file is 'EMP_XML_FILE.xml'
    <empno>U++kYmcVuGchxbh+++++++++++++++1+</empno>
    <empname>J</empname>
    suppose the empno 7501 is not available in our emp table,
    i got error
    ORA-03113: end-of-file on communication channel
    how to handle xmldom with no data values.
    by
    siva

    hi,
    please give the solution
    by
    siva

  • Applying table scroll bar for only table rows with table columns fixed.

    hi oa gurus,
    i had implemented table scroll bars using oarawtextbean , there is no problem in vertical and horizontal scroll bar working its working fine. but the requirement is i need to scroll only the table rows with table columns fixed. so , how to achieve the table scroll for only table datas neglecting table headers.
    the code for vertical and horizontal bars scroll is like this,
    OARawTextBean ors = (OARawTextBean)webBean.findChildRecursive("raw1");
    ors.setText(div id=tabledivid style=height:500px;width:100%; overflow:auto>);
    OARawTextBean ore = (OARawTextBean)webBean.findChildRecursive("raw2");
    ore.setText("</div>");
    where raw1 and raw2 are rawtextbean created above and below of the table . but i dont know hoow to apply this only for table rows neglecting table columns , can anybody give any ideas.
    pelase this is very urgent , can u help me in this regards
    thanks
    Edited by: user630121 on Sep 29, 2008 5:17 AM
    Edited by: user630121 on Sep 29, 2008 5:18 AM

    hi,
    I have a similar task to do... Only to apply scrollbar at the table level.
    I tried using the above mentioned but I am facing Null Pointer Exception..
    Please explain about raw1 and raw2
    Rahul

Maybe you are looking for

  • Cisco Anyconnect "Login Failed"

    in debug ldap 255, i see this message: memberOf: value = CN=L-NOUSA-VPN_Access,OU=Security Groups,OU=NOUSA,OU=PROD,DC=wmh-ag,DC=org [378534]                mapped to Group-Policy: value = GroupPolicy_WM-Wisconsin [378534]                mapped to LDA

  • Free busy Issue

    I recently setup a lion server and i imported calendar data,  user data via backup and restore,  and wikis via the wikiadmin script.  I am a linux admin mainly butcomfortable enough with macs.  Anyways i noticed that free-busy is not working with the

  • PDF - webdynpro problem

    Hi , I am trying to pull out a PDF document from the R3 backend thrrough webdynpro . we have a print reciept button on the screen , on pressing that a new internet explorer window is open . The problem is as soon as clicked on the button , the pdf is

  • How to deploy External library DC

    Currently I'm using NWDS 7.0.10. I'd like to deploy external library DC.(pls see attached for the details of errors) I can find the way to build external library DC in context tab of NWDS, but no way to deploy it in context tab of NWDS. How can I dep

  • 2nd phone same problem

    My wifes BB Curve 8330 Verizon at least twice a week has this problem. When she gets a call the person calling her can hear her but she cannot hear them. This happens randomly a couple of times a week. It does not make a difference if the call comes