Only GET records that have the same values of field has the same value in field B

Have a hard time with below, please help.

Here's the situation:

create table cord (identification NUMBER, CM VARCHAR2 (3), PM VARCHAR2 (2));
insert into string values (1, '002', 'H1');
insert into string values (2, '006', 'H1');
insert into string values (3, '004', 'H2');
insert into string values (4, '006', 'H2');
insert into string values (5, '004', 'H3');
insert into string values (6, '004', 'H3');

I just need to select the folders which, for the SAME value of PM have the same value in CM, in example above, those are recordings with ID (5,6).

1 and 2 fail because for them CM and PM are different for the same H1, similar on the 3 and 4.

I don't know if this will help but records are always in 'pairs', which means that there are no cases as

7. '004' | H4

8. ' 006' | H4

9. '005' | H4

Any ideas are much appreciated.

Thank you

See if the following can help...

select id,cm,pm
    from(
        select t.*
              ,count(1) over(partition by cm,pm) cnt
            from testt t
        )
    where cnt>1;

Tags: Database

Similar Questions

  • Stuck on a sql query to search for records that have the same parent child records

    Oracle 10 g 2 Enterprise Edition.

    Hello

    I'm writing a logic to find records in a parent table, who have the same values in a child table.
    This is part of a larger application, but I am stuck on that part for now, so I have mocked some of the below simplified tables to capture the heart of the
    the problem is that I'm stuck.
    Let's say I have a responsible parent, child employee table table and there are a number of many relationships between them.
    The aptly named Join_Table manages the relationship between them. If a manager can manage several employees, an employee can be managed by
    many managers.

    I have a feeling it's stupidly easy, but it seems to me having a bad episode of brain freeze today!
    -- parent table
    CREATE TABLE manager (
     id      number primary key,
     name      varchar2(100));
    
    -- child table 
    CREATE TABLE employee (
     id          number primary key,
     name      varchar2(100));
    
    -- link table
    CREATE TABLE join_table (
     manager_id          NUMBER, 
     employee_id      NUMBER,
     CONSTRAINT join_table_pk PRIMARY KEY (manager_id, employee_id),
     CONSTRAINT manager_fk FOREIGN KEY (manager_id) REFERENCES manager(id),
     CONSTRAINT employee_fk FOREIGN KEY (employee_id) REFERENCES employee(id) 
     );
    
    -- Insert some managers
    INSERT INTO manager (id, name) VALUES (1, 'John');
    INSERT INTO manager (id, name) VALUES (2, 'Bob');
    INSERT INTO manager (id, name) VALUES (3, 'Mary');
    INSERT INTO manager (id, name) VALUES (4, 'Sue');
    INSERT INTO manager (id, name) VALUES (5, 'Alan');
    INSERT INTO manager (id, name) VALUES (6, 'Mike');
    
    -- Insert some employees 
    INSERT INTO employee (id, name) VALUES (101, 'Paul');
    INSERT INTO employee (id, name) VALUES (102, 'Simon');
    INSERT INTO employee (id, name) VALUES (103, 'Ken');
    INSERT INTO employee (id, name) VALUES (104, 'Kevin');
    INSERT INTO employee (id, name) VALUES (105, 'Jack');
    INSERT INTO employee (id, name) VALUES (106, 'Jennifer');
    INSERT INTO employee (id, name) VALUES (107, 'Tim');
    
    -- Insert the links
    -- John manages Paul, Simon, Ken
    INSERT INTO join_table (manager_id, employee_id) VALUES (1, 101);
    INSERT INTO join_table (manager_id, employee_id) VALUES (1, 102);
    INSERT INTO join_table (manager_id, employee_id) VALUES (1, 103);
    -- Bob manages Paul, Simon, Kevin, Jack
    INSERT INTO join_table (manager_id, employee_id) VALUES (2, 101);
    INSERT INTO join_table (manager_id, employee_id) VALUES (2, 102);
    INSERT INTO join_table (manager_id, employee_id) VALUES (2, 104);
    INSERT INTO join_table (manager_id, employee_id) VALUES (2, 105);
    -- Mary manages Jennifer, Tim
    INSERT INTO join_table (manager_id, employee_id) VALUES (3, 106);
    INSERT INTO join_table (manager_id, employee_id) VALUES (3, 107);
    -- Sue manages Jennifer, Tim
    INSERT INTO join_table (manager_id, employee_id) VALUES (4, 106);
    INSERT INTO join_table (manager_id, employee_id) VALUES (4, 107);
    -- Alan manages Paul, Simon, Ken, Jennifer, Tim
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 101);
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 102);
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 103);
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 106);
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 107);
    -- Mike manages Paul, Simon, Ken
    INSERT INTO join_table (manager_id, employee_id) VALUES (6, 101);
    INSERT INTO join_table (manager_id, employee_id) VALUES (6, 102);
    INSERT INTO join_table (manager_id, employee_id) VALUES (6, 103);
    
    -- For sanity
    CREATE UNIQUE INDEX employee_name_uidx ON employee(name);
    If I ask for Manager John, so I want to find other managers who manage the exact list and even employees.
    Answer should be Mike.
    If I ask for Manager of Mary, the answer should be Sue.

    This query will give me the list of managers who manage some of the same employees as John, but not the same employees accurate...
    SELECT DISTINCT m.name AS manager
    FROM manager m, join_table jt, employee e
    WHERE m.id = jt.manager_id
    AND jt.employee_id = e.id
    AND e.id IN (
         SELECT e.id
         FROM manager m, join_table jt, employee e
         WHERE m.id = jt.manager_id
         AND jt.employee_id = e.id
         AND m.name = 'John')
    ORDER BY 1;
    I thought about using set operations to find managers with a list of employees less than my employees is null and where my employees under their list of employees is null. But there must be an easier way more elegant.
    Any ideas?
    BTW, I need to run as a batch on tables with > 20 million rows so the efficiency of queries is key.

    What about...

    WITH manager_list AS
    (
     SELECT name,
            LTRIM(MAX(SYS_CONNECT_BY_PATH(id,','))
            KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
     FROM   (SELECT m.name,
                    e.id,
                    ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr,
                    ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev
             FROM   manager m,
                    join_table jt,
                    employee e
      WHERE m.id           = jt.manager_id
      AND   jt.employee_id = e.id
      AND   m.name = :P_MANAGER)
      GROUP BY name
      CONNECT BY prev = PRIOR curr AND name = PRIOR name
      START WITH curr = 1
    ), all_list AS
    (
     SELECT name,
            LTRIM(MAX(SYS_CONNECT_BY_PATH(id,','))
            KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
     FROM   (SELECT m.name,
                    e.id,
                    ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr,
                    ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev
             FROM   manager m,
                    join_table jt,
                    employee e
      WHERE m.id           = jt.manager_id
      AND   jt.employee_id = e.id)
      GROUP BY name
      CONNECT BY prev = PRIOR curr AND name = PRIOR name
      START WITH curr = 1
    )
    SELECT a.*
    FROM   manager_list m,
           all_list a
    WHERE  m.employees = a.employees
    

    Would be easier in 11g, but I do not have a facility here so this is based on 10g.

    See you soon

    Ben

  • How to select all the records that have the difference of two dates of greater than a value

    Hi all

    I have a table as below:

    ID creation_date Modify_date

    --                -------------                                                            -----------

    1 10:11:07.243000000 JANUARY 7, 14 H 10:16:16.865000000 7 JANUARY 14 H

    2 13 JANUARY 14 12:07:27.603000000'M 12:08:09.955000000 13 JANUARY 14: 00

    I want to select all the IDs that is difference of Modify_date and creation_date is greater than 5 minutes.

    Please suggest how to achieve this goal, oracle database.

    TIA,

    Bob

    Select *.

    from table_name

    where (Modify_date - creation_date) * 1440 > = 5


    for timestamp:

    Select *.

    from table_name

    where extract (minute (Modify_date - creation_date)) > = 5



    -----

    Ramin Hashimzade

  • DO A RIGHT CLICK ANY ITEM IN THE MENU START. ONLY GET PROPERTIES THAT OPENS THE PROPERTIES 'TASKBAR '.

    This change has occurred in the last 30 days, but when I open the Start Menu I can are more done right click anything and get the 'Normal' list drop-down all appear is a box and she's 'Properties' and you open the properties of the task bar.

    Any ideas on how to fix - because I was not smart enough to run the restore when it appeared first, didn't want to try running through 15 or more of them.

    WIN VISTA HOME PREMIUM SP2 32-BIT

    Hello

    You had recently installed the software?

    Have you tried a system restore to the date and time before the problem occurred?

    Restart and start typing the F8 key

    Select Mode safe mode with networking

    Download the following and run a full scan to exclude the malware

    http://www.Microsoft.com/security/scanner/en-us/default.aspx

    When you are done, reboot and let Windows load

    Start > type CMD

    Right click on CMD and select run as administrator

    Type Sfc/scannow

    Press enter

    Note: There is a space between sfc and / scannow

    Use the System File Checker tool to repair missing or corrupted system files

    http://support.Microsoft.com/kb/929833/en-us

    The scan only takes a few minutes

    Open the taskbar and properties of the Start Menu by clicking on the Start button, clicking Control Panel, appearance and personalization, and then clicking the taskbar and Start Menu.

    Click the Start Menu tab, and then click Customize.

    In the Customize Start Menu dialog box, click on use default settings and then click OK.

  • query to view separate lines that have the same values

    Hello

    I have the columns id, addr1, addr2, city and State of coding. I need to know all the coding IDS that have the same addresses and at the same time filter out the same side of the id of the request.

    For example:

    acctid addr1, addr2 City State

    WEF 1 101 101 sd

    1                         101          wef     sd

    WEF 2 101 101 sd

    WEF 3 101 101 sd

    DC 4 102 102 homeless

    From the above data, I want to get filter tier 4 and get lines 1, 2 and 3. How to achieve with a sql query

    Thank you

    Arch

    This has nothing to do with hard... coding is how you test a query without creating the table, so you'd:

    with match_finder AS (SELECT acctid, addr1, addr2, city, State, count (*) OVER (PARTITION BY addr1, addr2, city, province) AS identical_rows)

    OF )

    Select acctid, addr1, addr2, city, province

    of match_finder

    where identical_rows > 1

    /

    and the rest, I'm sure, you can find on your own...

    HTH

  • two elements that have the same source

    Hi guys,.

    I am trying to use the display on a Google Map plugin location. As I had this plugin requires two elements that have the same source:

    Article 1 - A text to insert the value (address) in the database. The source of this question would be 'MAP' column.
    2 - Google Map plugin ELEMENT to visualize on the map. The source of this issue should also be "Map" the column that is used to read the address.

    But the problem, as you saw, we can not create a new record if we have two items with the same source. How can I get around this?

    Here is the link to the plugin:

    http://Apex.Oracle.com/pls/Apex/f?p=plugins:LOCATION_MAP:2943553726537511

    Kind regards
    Fateh

    Published by: Fateh July 21, 2011 02:52

    Hi Fateh,

    Tried the plugin you mentioned! Had a preview of your problem.
    >
    I am trying to use the display on a Google Map plugin location. As I had this plugin requires two elements that have the same source
    >
    As your form seems to be running automatic process line processing DML that will obviously give an error if you have two items
    with the same source i.e. 'MAP' that is your database column.
    >
    Article 1 - A text to insert the value (address) in the database. The source of this question would be 'MAP' column.
    >
    I think that this point is already with you as you may have created form based on a Table or form and report based on a Table.
    Leave the source of this article because it's IE card - the database column.
    >
    2 - Google Map plugin ELEMENT to visualize on the map.
    >
    Change the source of this article as:
    Source type: static assignment (value corresponds to the source attribute)
    Source of value or expression:

    &P1_ADDRESS.
    

    Where P1_ADDRESS is the element:
    >
    Article 1 - A text to insert the value (address) in the database. The source of this question would be 'MAP' column.
    >

    I hope that helps!
    Kind regards
    Kiran

  • Error: ' Pictures.library - ms no longer works. " This library can be removed safely from your computer. Records that have been added will not suffer' while accessing the image library.

    Title: Picures library no longer works?

    Whenever I try to open my library of images, I get the error message "Pictures.library - ms no longer works." This library can be removed safely from your computer. Records that have been added will not suffer. "It allows me to take pictures with my webcam or anything like that.

    Hi Love_atomic,

    Thanks for choosing Windows 8.
     
    I understand that you receive error message when trying to access the image library. I'll be happy to help you with this problem.
     
    (1) did you do changes on the computer before this problem?
    (2) is the issue limited only with the specific folder?
     
    I suggest you to follow the steps and check if the problem persists.
    (a) open Windows Explorer .
    (b) with the right button on image library , and select Remove.
    (c) click Yes to confirm.
    (d) then right click on libraries in the navigation pane.
    (e) select restore default libraries.

    Note: Deleting of a library does not delete the contents of the included folders. However, you need to add or include your folders manually, if necessary.
     
    I hope it helps. If you have problems in the future, please let us know. We will be happy to help you.
  • How to identify the virtual copies (in my records) that have already been deleted a collection

    Hello!

    I keep looking for an answer to this anywhere on the web and 3 books, but can't find the answer...

    How to identify the virtual copies (in my records) that have already been deleted a collection?

    Here's the workflow, and where I'm stuck.

    1. I chose a picture and put it in a collection.

    2. I did a whole bunch of virtual photos in the collection copies that I tried different modifications.

    3. after and during a lot of changes, I have a lot of virtual copies removed from my collection because I decided against the changes after doing some comparisons.

    4. when I went the folders to select my next picture to work away and so to add to the collection, I discovered that each of my virtual copies was in the original folder, even if I had deleted from my collection.

    5. I really don't want these virtual copies deleted to be in my home folder.  They were virtual copies of trial and error and I wanted them to really just be thrown out.

    6. how to identify these virtual copies removed-from-the-collection in my folder?  File names all look the same, and besides, I want to be absolutely certain that I have selected the right ones.  Some of the changes were very minor and would be difficult to see without laboriously go through them one by one.

    Thank you very much!!

    Anne

    No easy answer on fixing the mess other than an individual inspection of the virtual copy can't watching the Images/Edit history to determine which ones that you no longer need.

    But to help prevent the problem in the future: when you are working from a collection, you must use ALT + return back to remove a copy of Photo or virtual catalog. With just the key DELETE or BACKSPACE only deletes the photo from the collection.

  • Selection of the records that have no referencing records at a small price

    I try to get records that has no records of references. Here's the script and test the query I wrote to get the result.
    I can get result, but my problem is to lower the cost. This table has more than 50,000 rows. Hope someone can guide me to write a better query.

    create table ot_req (rh_sysid rh_txn_type VARCHAR2 (NO.4), rh_ref_sys_id (5), (4), rh_ref_txn_cod VARCHAR2 (5));

    INSERT INTO ot_req VALUES (800, 'MR SS', NULL, NULL);
    INSERT INTO ot_req VALUES(801,'SSPR',800,'SSMR');
    INSERT INTO ot_req VALUES(810,'SSMR',,);
    INSERT INTO ot_req VALUES(811,'SSMR',,);
    INSERT INTO ot_req VALUES(812,'SSMR',,);
    INSERT INTO ot_req VALUES(813,'SSPR',812,'SSMR');
    INSERT INTO ot_req VALUES(814,'SSMR',,);
    INSERT INTO ot_req VALUES(815,'SSPR',814,'SSMR');


    SELECT
    rh_sysid
    Of
    ot_req
    WHERE
    rh_sysid
    PO NO
    (SELECT
    rh_ref_sys_id
    Of
    ot_req
    WHERE
    rh_ref_sys_id IS NOT NULL)
    AND
    rh_txn_type! = "SŠPR";

    Result

    RH_SYSID
    810
    811

    Looking forward to your support.

    Thanks in advance :)

    Unus wrote:
    My problem is to lower the cost.

    rh_ref_sys_id will never be sšpr. Only sšpr will reference number

    SQL> exec dbms_stats.gather_table_stats(user,'ot_req')
    
    PL/SQL-procedure is geslaagd.
    
    SQL> set autotrace on
    SQL> select rh_sysid
      2    from ot_req
      3   where rh_sysid not in
      4         ( select rh_ref_sys_id
      5             from ot_req
      6            where rh_ref_sys_id is not null
      7         )
      8     and rh_txn_type!='SSPR'
      9  /
    
      RH_SYSID
    ----------
           810
           811
    
    2 rijen zijn geselecteerd.
    
    Uitvoeringspan
    ----------------------------------------------------------
    Plan hash value: 2746377339
    
    -----------------------------------------------------------------------------
    | Id  | Operation          | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    -----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |        |     5 |    60 |     7  (15)| 00:00:01 |
    |*  1 |  HASH JOIN ANTI SNA|        |     5 |    60 |     7  (15)| 00:00:01 |
    |*  2 |   TABLE ACCESS FULL| OT_REQ |     5 |    50 |     3   (0)| 00:00:01 |
    |*  3 |   TABLE ACCESS FULL| OT_REQ |     3 |     6 |     3   (0)| 00:00:01 |
    -----------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - access("RH_SYSID"="RH_REF_SYS_ID")
       2 - filter("RH_TXN_TYPE"<>'SSPR')
       3 - filter("RH_REF_SYS_ID" IS NOT NULL)
    
    Statistics
    ----------------------------------------------------------
              1  recursive calls
              0  db block gets
             14  consistent gets
              0  physical reads
              0  redo size
            469  bytes sent via SQL*Net to client
            416  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              2  rows processed
    
    SQL> select nvl(rh_ref_sys_id,rh_sysid) rh_sysid
      2    from ot_req
      3   group by nvl(rh_ref_sys_id,rh_sysid)
      4  having count(*) = 1
      5  /
    
      RH_SYSID
    ----------
           810
           811
    
    2 rijen zijn geselecteerd.
    
    Uitvoeringspan
    ----------------------------------------------------------
    Plan hash value: 2435394825
    
    ------------------------------------------------------------------------------
    | Id  | Operation           | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    ------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT    |        |     1 |     6 |     4  (25)| 00:00:01 |
    |*  1 |  FILTER             |        |       |       |            |          |
    |   2 |   HASH GROUP BY     |        |     1 |     6 |     4  (25)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL| OT_REQ |     8 |    48 |     3   (0)| 00:00:01 |
    ------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter(COUNT(*)=1)
    
    Statistics
    ----------------------------------------------------------
              1  recursive calls
              0  db block gets
              7  consistent gets
              0  physical reads
              0  redo size
            469  bytes sent via SQL*Net to client
            416  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              2  rows processed
    

    Kind regards
    Rob.

  • How to identify columns that have the same data in a SQL query or function?

    Deal all,

    How to identify columns that have the same data in a SQL query or function? I have the sample data as below

    DEPT_IDEMP_IDCome on
    !CITYSTATECOUNTRY111 June 1983DELHIHUMAN RESOURCESIndia1218 January 1987DELHIHUMAN RESOURCESIndia1328 November 1985DELHIHUMAN RESOURCESIndia144 June 1985DELHIHUMAN RESOURCESIndia255 June 1983MUMBAIHDIndia266 June 1983MUMBAIHDIndia277 June 1983MUMBAIHDIndia288 Jun. 1983MUMBAIHDIndia399. June 1983GURGAONDLIndia31010 June 1983GURGAONDLIndia

    Now, I want to Indify columns that have the same data for the same Department ID.

    Is it possible in sql unique or do I have to write the function for this? Pls Help how to write?

    Thanks in advance.

    You can try this?

    WITH T1)

    DEPT_ID, EMP_ID, DATE OF BIRTH, CITY, STATE, COUNTRY

    ), ()

    SELECT 1, 1, TO_DATE('1.) June 1983', 'JJ. LUN. (YYYY'), 'DELHI', 'HR', 'INDIA' OF THE DUAL UNION ALL

    SELECT 1, 2, TO_DATE('18.) January 1987', 'JJ. LUN. (YYYY'), 'DELHI', 'HR', 'INDIA' OF THE DUAL UNION ALL

    SELECT 1, 3, TO_DATE('28.) November 1985', 'JJ. LUN. (YYYY'), 'DELHI', 'HR', 'INDIA' OF THE DUAL UNION ALL

    SELECT 1, 4, TO_DATE('4.) June 1985', 'JJ. LUN. (YYYY'), 'DELHI', 'HR', 'INDIA' OF THE DUAL UNION ALL

    SELECT 2.5, TO_DATE('5.) June 1983', 'JJ. LUN. (YYYY'), 'BOMBAY', 'HD', 'INDIA' OF THE DUAL UNION ALL

    SELECT 2.6, TO_DATE('6.) June 1983', 'JJ. LUN. (YYYY'), 'BOMBAY', 'HD', 'INDIA' OF THE DUAL UNION ALL

    SELECT 2.7, TO_DATE('7.) June 1983', 'JJ. LUN. (YYYY'), 'BOMBAY', 'HD', 'INDIA' OF THE DUAL UNION ALL

    SELECT 2.8, TO_DATE('8.) June 1983', 'JJ. LUN. (YYYY'), 'BOMBAY', 'HD', 'INDIA' OF THE DUAL UNION ALL

    SELECT 3, 9, TO_DATE('9.) June 1983', 'JJ. LUN. (YYYY'), 'GURGAON', 'DL', 'INDIA' OF THE DUAL UNION ALL

    SELECT 3.10, TO_DATE('10.) June 1983', 'JJ. LUN. (YYYY'), 'GURGAON', 'DL', 'INDIA' OF THE DOUBLE)

    SELECT DEPT_ID,

    RTRIM (XMLAGG (XMLELEMENT(A,VALS||',')). Extract ('//Text ()'), ',') COLUMNS_WITH_DUPLICATE

    DE)

    SELECT * FROM)

    SELECT DEPT_ID,

    EMP_ID,

    Date of birth

    CITY,

    STATE,

    COUNTRY

    DE)

    SELECT DEPT_ID,

    EMP_ID,

    Date of birth

    CITY,

    STATE,

    COUNTRIES,

    COUNT (*) OVER(PARTITION BY DEPT_ID ORDER BY EMP_ID DESC,DOB DESC,CITY DESC,STATE DESC, COUNTRY DESC) RN

    DE)

    SELECT DEPT_ID,

    CASE WHEN(CEID>1) AND THEN 'YES' ELSE 'NO' END AS EMP_ID.

    CASE WHEN(CDOB>1) THEN 'YES' ELSE 'NO' END AS DATE OF BIRTH,

    CASE WHEN(CCITY>1) AND THEN 'YES' ELSE 'NO' END AS CITY.

    CASE WHEN(CSTATE>1) AND THEN 'YES' ELSE 'NO' END AS STATE.

    CASE WHEN(CCOUNTRY>1) THEN 'YES' ELSE 'NO' END AS A COUNTRY

    DE)

    SELECT DISTINCT

    DEPT_ID,

    CEID,

    CDOB,

    CITY,

    CSTATE,

    CCOUNTRY

    DE)

    SELECT DEPT_ID,

    COUNT (*) TO THE CEID (DEPT_ID PARTITION, EMP_ID),.

    COUNT (*) ON CDOB (DEPT_ID SCORE, DATE OF BIRTH),

    COUNT (*) ON THE CITY (DEPT_ID PARTITION, CITY),

    COUNT (*) ON CSTATE (DEPT_ID PARTITION, STATE).

    COUNT (*) ON CCOUNTRY (DEPT_ID, COUNTRY PARTITION)

    FROM T1)))

    WHERE RN = 1)

    UNPIVOT (CLO FOR (VALS) IN (EMP_ID, DATE OF BIRTH, CITY, STATE, COUNTRY)))

    WHERE COLS = "YES".

    DEPT_ID GROUP;

    OUTPUT:

    DEPT_ID COLUMNS_WITH_DUPLICATE
    --------- ------------------------

    1 CITY, COUNTRY, STATE
    2 CITY, COUNTRY, STATE
    3 CITY, COUNTRY, STATE

    Post edited by: Parth272025

  • How to remove the lines that have the employee name double?

    Hello world

    Greetings

    I'm using oracle 11g.

    Suppose I have a table and I want to delete lines that have the name used twice?

    So given below is my table so I only delete lines that have more than one 'Ram' and 'Dilip' ename.

    How to do this?

    EmpID Ename salary Commission depnto
    101RAM50004531
    102RAM60007652
    103Sisi34568763
    104Dilip76566754
    105Mohan98787675
    106Dilip56469876
    107Ganesh98234557

    You can use a simple code as follows

    Delete From EMP

    Where rowid! = (select min (rowid) of the group by Ename EMP);

    For preserved older values using 'min (rowid)'

    and for the most recent values required use "max (rowid)"

    Thank you.

  • Query to retrieve records that have more than one assignment_id

    Hello

    I'm writing a query to extract all records in the table per_all_assignments_f that has more than one different assignment_id for each person_id. Here's the query I wrote, it retrieves the records, even if a person_id assignment_id duplicate, but I need records that have more than one assignement_id without duplicate for each person_id

    Select assignment_id, person_id, assignment_id
    Of per_all_assignments_f
    Having count (assignment_id) > 1
    Person_id group, assignment_id

    Thank you.
    PK

    Maybe something like that?

    select *
    From   per_all_assignments_f f1
    where  exists (select 1
                   from   per_all_assignments_f f2
                   where  f2.person_id = f1.person_id
                   and    f2.assignment_id != f1.assignment_id
                  );
    

    Published by: SomeoneElse on May 7, 2010 14:23

    (you can add a SEPARATE from the outer query if you wish)

  • Using Windows 7 and LR 5 when I look at the list of keywords a keyword has 7 photos but when I check the library with this 350 photos filter keywords appear which includes 7 photos that have the keyword.  Why the showi filter library

    The use of Windows 7 and LR 5, when I look at the list of keywords a keyword has 7 photos but when I check the library with this 350 photos filter keywords appear which includes 7 photos that have the keyword.  Why the library filter, showing images that do not match the query

    John,

    Thank you very much for the work you've put into this.  I made the change you suggested making the subkeywords under 'schwartz' to be {name schwartz}.  I don't know who has contributed something, but I think that there are more immediate problem which is mucked up.  As well as the fact that I have several catalogs that I don't know how they were created, I think that the best thing would be to merge all the catalogs into one (it is better to have a single catalog, right?) and delete all the keywords from scratch.

    Thanks for your help.  I'll mark this as resolved issue.

    Dan

  • Read the nodes that have the same value as the subnodes - XML

    It is more of a general JAVA / XML problem, but given that it is going into my BlackBerry app I thought I'd see if anyone knows.

    Consider a simple XML document:

                        Whatever 1                   Whatever 2               Whatever 3       
    

    Using the standard org.w3c.dom, I can get the nodes in X by the practice...

    NodeList fullnodelist = doc.getElementsByTagName ("x");

    But if I want to go to the next set of 'e', I try to use something like...

    Element element = (Element) fullnodelist.item(0);NodeList nodes = pelement.getElementsByTagName("e");
    

    EXPECTED back '3' nodes (because there are 3 series of 'e'), but it returns '9' - because it gets all entries including the 'e' apperently.

    It would be nice in the above case, because I could probably go through and find what I'm looking for. The problem I have is that when the XML file looks like the following:

                whatever              Something Else                    whatever              Something Else            
    

    When I ask 'e' value, it returns 4, instead of (what I want) 2.

    I am simply not understand how DOM parsing works? Generally, in the past I used my own XML documents so I name never articles like this, but unfortunately this isn't my XML file and I don't have the choice to work like this.

    What I thought I would do, it is write a loop knots "drills down" so that I can combine each node...

      public static NodeList getNodeList(Element pelement, String find)
        {
            String[] nodesfind = Utilities.Split(find, "/");
            NodeList nodeList = null;
    
            for (int i = 0 ; i <= nodesfind.length - 1; i++ )
            {
                nodeList = pelement.getElementsByTagName( nodesfind[i] );
                pelement = (Element)nodeList.item(i);
            }
    
            // value of the nod we are looking for
            return nodeList;
        }
    

    .. While if adopted you ' s/e' in the service, he would return the 2 nodes I'm looking (or elements, perhaps I'm using the wrong terminology?). on the contrary, it returns all the 'e' nodes in this node.

    Anyway, if anyone is still with me and has a suggestion, it would be appreciated.

    Well, there is no doubt that there is a learning curve robust for XML programming. You can take an hour or two and go through one of the tutorials that are circulating on the net. (Like that of w3schools.com.)

    Basically, almost everything in XML is a node, the Document that returns the parser. The API for node tells you that you can test the node type you have by calling getNodeType, which returns one of the constants of type node (Node.ELEMENT_NODE, Node.TEXT_NODE, etc..) If necessary, you can then convert the variable to the corresponding interface (element, text, etc.).

    Similarly, the API documentation say you for any node, calling getChildNodes (or for an element node or Document getElementsByTagName) will give you a NodeList (a little non-types of nodes in the XML API), while calling getFirstChild and getNextSibling to any node will give you another node (or null ).

    Once you learn the API, writing logic of course is not all that hard. For example, if the only 'e' interest tags are those directly under the element root of the document (as shown in your example) you can simply go to them directly:

    Vector getTopENodes(Document doc) {  Vector vec = new Vector();  NodeList nodes = doc.getDocumentElement().getChildNodes();  int n = nodes.getLength();  for (int i = 0; i < n; ++i) {    Node node = nodes.item(i);    if (node.getNodeType() == Node.ELEMENT_NODE &&        "e".equals(node.getNodeName()))    {      vec.addElement(node);    }  }  return vec;}
    

    Note that this example does not assume that all children are nodes of element 'e '. the document could have comments, white space or something else that makes it into the DOM as comment, text or any other type of node.

    On the other hand, if you want to capture every "e" tag which is directly under the ' tag, no matter the level, then you need to do something a little more complicated (it's on the top of my head - no guarantee):

    static class NodeListImp implements NodeList {  private Vector nodes = new Vector();  public int getLength() {    return nodes.size();  }  public Node item(int index) {    return (Node) nodes.elementAt(index);  }  public add(Node node) {    nodes.addElement(node);  }}
    
    NodeList getTargetNodes(Document doc) {  NodeListImp list = new NodeListImp();  getTargetnodes(list, doc.getDocumentElement(), false);  return list;}
    
    void getTargetNodes(NodeListImp list, Node node, boolean parentIsS) {  if (node.getNodeType() == Node.ELEMENT_NODE) {    // node name is tag name for element nodes    String name = node.getNodeName();    if (parentIsS && "e".equals(name)) {      list.add(node);    }    parentIsS = "s".equals(name);    for (Node child = node.getFirstChild();         child != null;         child = child.getNextSibling())    {      getTargetNodes(list, child, parentIsS);    }  }}
    

    I hope that it gets the idea across.

  • Can I get the total number of records that meet the conditions of a query using the Table API?

    Hello

    A < row > TableIterator is returned when I ask operations using the index of tables. If I want to get the total number of records, I count one by one using the returned TableIterator < row >.


    Can I get the total number of records directly meets the conditions of the query?

    I can get the total number of records directly the request of the meeting of the conditions of CLI using the command Global table - name tableName - count - index index-name-field fieldName - start startValue-end endValue.

    Can I get the same results using the Table API?

    I used MongoDB and NoSQL Oracle for about a year. According to the experience of the use of these dbs, I think mongoDB querying interface is powerful. In the contras, the query interface is relatively simple, which results is a lot of work that is usually a long time in the client side.

    Hello

    Counting records in a database is a tricky thing.  Any system that gives you an accurate count of the records will have a hotspot of concurrency on updates, namely the place where the counting is maintained.  Such a count is a problem of performance in addition to competitive access problem.   The problem is even more difficult in a system widely distributed such a NoSQL database.

    The CLI has overall command that counts, but does so by brutal force - iterate keys that correspond to the parameters of the operation.  This is how you must do this within the API.  There is not a lot of code, but you have to write.  You certainly want to use TableIterator TableAPI.tableKeysIterator (), because a key iteration is significantly faster than the iteration of lines.  Just one iteration and count.

    If you use TableAPI.multiGet () and a key with a touch of brightness full then, in fact, count the results as they are returned in a single piece (a list).

    Kind regards

    George

Maybe you are looking for