Query to search for recursive data

Hello
I have a table called orders that has two columns, orderid and originalorderid. the data from this column as below:

OrderId Active OriginalOrderId
6 0
11 6 0
14-11-1

I want to write a query such that when I pass the orderid = 14 it returns me OrderID 6 and 11 6 being the first orderid that changed 11 orderid, then 14 orderid.
How can I write such a request.

Please notify.

Thank you
Reena

Hello

@ Centinel: thanks for you Centinel SAMPLES.

WITH orders AS
    (
            SELECT 6  AS ORDERID, 0  AS ORIGINALORDERID, NULL       AS ACTIVE FROM DUAL UNION ALL
           SELECT 11 AS ORDERID, 6  AS ORIGINALORDERID, 0          AS ACTIVE FROM DUAL UNION ALL
           SELECT 14 AS ORDERID, 11 AS ORIGINALORDERID, 1          AS ACTIVE FROM DUAL
    )           SELECT  max(ltrim(SYS_CONNECT_BY_PATH(ORDERS.ORDERID, ','),','))keep(dense_rank last order by level  )res
           FROM    ORDERS
           START WITH ORDERID != 14
           CONNECT BY ORDERID = PRIOR ORIGINALORDERID
/
RES
--------------------------------------------------------------------------------
11,6

SQL> 

Tags: Database

Similar Questions

  • query to search for the user of the application

    Hello

    What is the query to search for the user of the application in the sql command?

    I tried the query below
    select app_user from dual;
    app_user invalid identifier
    Thank you.

    Hello skud,
    The following SQL statement will give you the APP_USER which is an environmental variable in the APEX:

    SELECT v('APP_USER') FROM DUAL;
    

    See if it works. As I used the syntax given in the triggers to record audit trail above and it works fine.
    Kiran

    Published by: chubby Kiran June 11, 2011 04:08

    Published by: chubby Kiran June 11, 2011 04:09

  • SQL - last selection query save values for each date in term

    Hello

    Can anyone help me please with my problem.

    I'm trying to get the last balance recorded for each day of specific box (1 or 2) in a given period of days of the database ms access using ADOTool.

    I'm trying to get this information with SQL query but so far without success.

    My table looks like this:

    Name of the table: TestTable

    Date         Time      Location  Box  Balance
    20.10.2014.  06:00:00     1       1    345
    20.10.2014.  12:00:00     1       1    7356
    20.10.2014.  18:45:00     1       1    5678
    20.10.2014.  23:54:00     1       1    9845
    20.10.2014.  06:00:02     1       2    35
    20.10.2014.  12:00:04     1       2    756
    20.10.2014.  18:45:06     1       2    578
    20.10.2014.  23:54:10     1       2    845
    21.10.2014.  06:00:00     1       1    34
    21.10.2014.  12:05:03     1       1    5789
    21.10.2014.  15:00:34     1       1    1237
    21.10.2014.  06:00:00     1       2    374
    21.10.2014.  12:05:03     1       2    54789
    21.10.2014.  15:00:34     1       2    13237
    22.10.2014.  06:00:00     1       1    8562
    22.10.2014.  10:00:00     1       1    1234
    22.10.2014.  17:03:45     1       1    3415
    22.10.2014.  22:00:00     1       1    6742
    22.10.2014.  06:00:05     1       2    562
    22.10.2014.  10:00:16     1       2    123
    22.10.2014.  17:03:50     1       2    415
    22.10.2014.  22:00:10     1       2    642
    23.10.2014.  06:00:00     1       1    9876
    23.10.2014.  09:13:00     1       1    223
    23.10.2014.  13:50:17     1       1    7768
    23.10.2014.  19:47:40     1       1    3456
    23.10.2014.  21:30:00     1       1    789
    23.10.2014.  23:57:12     1       1    25
    23.10.2014.  06:00:07     1       2    976
    23.10.2014.  09:13:45     1       2    223
    23.10.2014.  13:50:40     1       2    78
    23.10.2014.  19:47:55     1       2    346
    23.10.2014.  21:30:03     1       2    89
    23.10.2014.  23:57:18     1       2    25
    24.10.2014.  06:00:55     1       1    346
    24.10.2014.  12:30:22     1       1    8329
    24.10.2014.  23:50:19     1       1    2225
    24.10.2014.  06:01:00     1       2    3546
    24.10.2014.  12:30:26     1       2    89
    24.10.2014.  23:51:10     1       2    25
    ...
    

    Let's say that the period is 21.10.2014. -23.10.2014. and I want to get the last balance recorded for zone 1. for each day. The result should look like this:

    Date         Time      Location  Box  Balance
    21.10.2014.  15:00:34     1       1    1237
    22.10.2014.  22:00:00     1       1    6742
    23.10.2014.  23:57:12     1       1    25
    

    So far, I managed to write a query that gives me the balance so that a SINGLE date (date more time in the table), but I need balance for EACH date in a specific period.

    My incorrect code (has not managed to implement "BETWEEN" for the dates...):

    SELECT TestTable.[Date], TestTable.[Time], TestTable.[Location], TestTable.[Box], TestTable.[Balance]
    FROM TestTable
    WHERE Time=(SELECT MAX(Time)
    FROM TestTable
    WHERE Location=1 AND Box=1 );
    

    TNX!

    NP

    Here's the correct query (just copy - paste):

    SELECT
    T1.Date,
    T1.Time,
    T1.Location,
    T1.Box,
    T1.Balance
    FROM TestTable T1
    INNER JOIN (
    SELECT
    MAX(Time) AS Max_Time
    FROM TestTable
    WHERE Location=1 AND Box=1 AND Date BETWEEN #10/27/2014# AND #11/1/2014#
    GROUP BY Date) T2
    ON T1.Time=T2.Max_Time;
    

    The problem is in the SELECTION within the INNER JOIN. This SELECTION selects the time max for each date, because we want this and then the entire table, we choose filelds we want, but now we have only fields with the time max.

    Here is a really good explanation of INNER JOIN if anyone is interested--> JOINT INTERNAL

    Peace!

  • How can I search for specific dat ramges in Windows 7

    Hi, I had to buy a new compuiter and it came with Windows 7 and I can't figure out where the comand of research is - I think that disappeared - and the search on the file header is not get everything I need.  I need to find, for example, all the files that I wrote in January 2008, which contains the word "Record".  Is it possible to download the XP: Microsoft's search engine and use in Windows 7? The XP search all done perfectly.   Let me know, Joe

    Hello

    References to Vista also apply to Windows 7.

    Windows Search does not work or research are slower
    http://support.Microsoft.com/GP/windows_search

    Troubleshooting Windows Vista search & indexing errors
    http://www.WinVistaClub.com/T24.html

    Reconstruction of the Index in Windows Vista
    http://www.howtogeek.com/HOWTO/Windows-Vista/rebuilding-the-search-index-in-Windows-Vista/
    How to enable or disable the search Index in Vista
    http://www.Vistax64.com/tutorials/69564-index-enable-disable.html
    Improve Windows searches using the index: frequently asked questions
    http://Windows.Microsoft.com/en-us/Windows-Vista/improve-Windows-searches-using-the-index-frequently-asked-questions

    ================================

    Tips for finding files
    http://Windows.Microsoft.com/en-us/Windows-Vista/tips-for-finding-files

    How to use advanced search in Vista Options
    http://www.Vistax64.com/tutorials/75451-advanced-search.html

    How to restore the page button on the Start Menu after installing Vista SP1
    http://www.Vistax64.com/tutorials/145787-Search-start-menu-button-restore-after-SP1.html

    How to restore the context Menu item search after installing Vista SP1
    http://www.Vistax64.com/tutorials/134065-search-context-menu-item-restore-after-Vista-SP1.html

    How to create a shortcut on the desktop search in Vista
    http://www.Vistax64.com/tutorials/126499-search-desktop-shortcut.html

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

    Win Key F opens advanced search

    Searching in Windows Vista, part 1
    http://Windows.Microsoft.com/en-us/Windows-Vista/searching-in-Windows-Vista-part-1-secrets-of-the-search-box

    Part 2
    http://Windows.Microsoft.com/en-us/Windows-Vista/searching-in-Windows-Vista-part-2-Start-menu-and-control-panel-search-tips

    Part 3
    http://Windows.Microsoft.com/en-us/Windows-Vista/searching-in-Windows-Vista-part-3-using-advanced-search-for-those-hard-to-find-files

    I hope this helps.
    Rob - bicycle - Mark Twain said it is good.

  • Slow down the search for the data source

    For j2me so Media Player I open a connection file (in a local file) and get an inputstream and passing to the player I have no problem loading the file/search.

    On the other hand, I wrote my own simple data source wraps simply a connection file and an Inputstream, when I try to read a large file the app just crashes. I think that what the Player tries to do is read the entire file for the headers, but why is there this difference in speed?

    NM, the reason why it was slow was because I was enveloping the stream in an input stream shared

  • SQL query to search for the line that contains the identifier for each consecutive group

    Hello

    I'm on 11.2.0.3 Enterprise Edition.

    I have a strange request here - do not know if this is possible without going to procedure...

    Given these data of the sample:

    create table test_status (
      status varchar2(10),
      revision_id number,
      revision_timestamp timestamp);
    
    insert into test_status values ('PROPOSED', 1, systimestamp);
    insert into test_status values ('PROPOSED', 2, systimestamp);
    insert into test_status values ('PROPOSED', 3, systimestamp);
    insert into test_status values ('ACTIVE', 4, systimestamp);
    insert into test_status values ('ACTIVE', 5, systimestamp);
    insert into test_status values ('PROPOSED', 6, systimestamp);
    insert into test_status values ('PROPOSED', 7, systimestamp);
    insert into test_status values ('ACTIVE', 8, systimestamp);
    insert into test_status values ('ACTIVE', 9, systimestamp);
    insert into test_status values ('FINISHED', 10, systimestamp);
    insert into test_status values ('FINISHED', 11, systimestamp);
    insert into test_status values ('FINISHED', 12, systimestamp);
    

    Gives me:

    SQL> select *
      2  from test_status
      3  order by revision_id;
    
    
    STATUS     REVISION_ID REVISION_TIMESTAMP
    ---------- ----------- -----------------------------
    PROPOSED             1 25-SEP-14 04.49.47.954000 PM
    PROPOSED             2 25-SEP-14 04.49.47.962000 PM
    PROPOSED             3 25-SEP-14 04.49.47.966000 PM
    ACTIVE               4 25-SEP-14 04.49.47.969000 PM
    ACTIVE               5 25-SEP-14 04.49.47.972000 PM
    PROPOSED             6 25-SEP-14 04.49.47.976000 PM
    PROPOSED             7 25-SEP-14 04.49.47.979000 PM
    ACTIVE               8 25-SEP-14 04.49.47.982000 PM
    ACTIVE               9 25-SEP-14 04.49.47.987000 PM
    FINISHED            10 25-SEP-14 04.49.47.991000 PM
    FINISHED            11 25-SEP-14 04.49.47.996000 PM
    FINISHED            12 25-SEP-14 04.49.48.000000 PM
    
    
    12 rows selected.
    ws selected.
    

    I want to get this result:

    STATUS     REVISION_ID REVISION_TIMESTAMP
    ---------- ----------- ----------------------------
    PROPOSED             3 25-SEP-14 04.49.47.966000 PM
    ACTIVE               5 25-SEP-14 04.49.47.972000 PM
    PROPOSED             7 25-SEP-14 04.49.47.979000 PM
    ACTIVE               9 25-SEP-14 04.49.47.987000 PM
    FINISHED            12 25-SEP-14 04.49.48.000000 PM
    

    Then query the table ordered by Revision_Id, I would get the line containing the highest revision for each consecutive group of status values.  I am able to get the line containing the highest revision for each separate status, value, but I can't deal with the scenario where a state value reappears later.  In the case of the real world, it is a workflow and I need to take into account the fact that an element through the workflow may be redirected to the back front she proceeds forward again.

    Hope it makes sense.

    Thank you

    John

    Hi, John,.

    John OToole (Dublin) wrote:

    Hello

    I'm on 11.2.0.3 Enterprise Edition.

    I have a strange request here - do not know if this is possible without going to procedure...

    ...

    Do not no stinkin' procedure:

    WITH got_grp_id AS

    (

    SELECT the status, revision_id, revision_timestamp

    ROW_NUMBER () OVER (ORDER BY revision_id)

    -ROW_NUMBER () (PARTITION STATUS

    ORDER BY revision_id

    ) AS grp_id

    OF test_status

    )

    SELECT status

    MAX (revision_id) AS revision_id

    MAX (revision_timestamp) DUNGEON (DENSE_RANK LAST ORDER BY revision_id)

    AS revision_timestamp

    OF got_grp_id

    GROUP BY status, grp_id

    ORDER BY revision_id

    ;

    For an explanation of the technique of Difference sets used here, see

    Analytic Question lag and lead and/or

    Re: Ranking of queries

  • Query to search for students by group ID

    Hello

    I have a table that has 2 columns student_id and Course_id.

    Examples of data

    Student_id Course_id
    -------------------------------
    1 > 1
    1 > 2
    1 > 3
    1 > 4
    2 > 1
    2 > 3
    3 > 1
    3 > 2
    3 > 4
    I want to find students who have completed all course 1,3,4.

    Try again with the following query.

    WITH T AS (SELECT 1 stu_id ,     1 stu_curs FROM DUAL
     UNION ALL
    SELECT 1 ,     2 FROM DUAL
     UNION ALL
    SELECT 1 ,     3 FROM DUAL
     UNION ALL
    SELECT 1 ,     4 FROM DUAL
     UNION ALL
    SELECT 2 ,     1 FROM DUAL
     UNION ALL
    SELECT 2 ,     3 FROM DUAL
     UNION ALL
    SELECT 3 ,     1 FROM DUAL
     UNION ALL
    SELECT 3 ,     2 FROM DUAL
     UNION ALL
    SELECT 3 ,     4 FROM DUAL
     )
    select stu_id from t where stu_curs in (1,3,4) group by stu_id having count(0) = 3;
    
  • Query to search for users based on the State of the resource

    Hi all

    I'm working on version 9 x IOM. I need to find all the users of a resource that is in "Ready" status in the profile of their resources

    Let say resource Genetiquea is here and for some users of the status of this resource in their resources profile is in "ready". I want to get these users.

    Melyssa, help me with this SQL query.

    Thank you
    Madhu

    Try this query:
    Select usr.usr_login, obj.obj_name, ost.ost_status, usr, obj, obi, Ouedraogo, ost where usr.usr_key = oiu.usr_key and obi.obi_key = oiu.obi_key and obi.obj_key = obj.obj_key and ost.ost_key = oiu.ost_key and obj.obj_name =''

    You can add: and ost.ost_status = to find the status as well.

    Kind regards
    GP

  • 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

  • SQL query to search for a single line

    Hi All-
    I have a requirement where I have to get the id who subscribe only to a single course based on data below.

    ID courses
    103812 CFH
    102968 REP
    103812 DFH
    DFH 102968
    103071 DFH
    CFH 102968

    CREATE TABLE classes
    (IDENTIFICATION NUMBER,
    course VARCHAR2 (3));

    insert into class values (103812, "CFH");
    insert into class values (102968, "REP");
    insert into class values (103812, "DFH");
    insert into class values (102968, "DFH");
    insert into class values (103071, "DFH");
    insert into class values (102968, "CFH");

    SELECT THE ID
    IN THE COURSE OF
    GROUP BY ID
    AFTER HAVING COUNT (RACE) = 1;

  • Cross connection request, search for unpaired data

    Always on Oracle 11.2.0.1.0

    Sample data:

    In connectionA
    CREATE TABLE datasampleA (
             RID NUMBER(10) PRIMARY KEY,
             employeeNumber NUMBER(9),
              employeeName VARCHAR2(15),
             jobID VARCHAR2(10),
             job_date   DATE,
             active  NUMBER(9)
           )
    ;
     
    INSERT INTO datasampleA VALUES(121420,100171,'Jack',411,'03-JUN-99',1);
    INSERT INTO datasampleA VALUES(119590,100244,'Elizabeth',409,'13-SEP-99',1);
    INSERT INTO datasampleA VALUES(124252,100352,'Amy',7646,'25-MAY-08',1);
    INSERT INTO datasampleA VALUES(124253,100514,'Jonathan',642,'06-MAR-05',1);
    INSERT INTO datasampleA VALUES(116592,100526,'Ruben',642,'20-FEB-05',1);
    INSERT INTO datasampleA VALUES(116593,100526,'Ruben',7646,'20-FEB-05',0);
    INSERT INTO datasampleA VALUES(122273,100526,'Ruben',7646,'12-JAN-03',0);
    INSERT INTO datasampleA VALUES(121142,100615,'Peter',7646,'21-JUN-99',1);
    INSERT INTO datasampleA VALUES(116594,100822,'Kathee',642,'20-MAR-05',1);
    INSERT INTO datasampleA VALUES(119354,100890,'Christopher',7647,'28-AUG-11',0);
    INSERT INTO datasampleA VALUES(417079,100890,'Christopher',7646,'28-AUG-11',1);
    INSERT INTO datasampleA VALUES(122128,100946,'Christopher',411,'11-MAR-02',1);
    INSERT INTO datasampleA VALUES(118382,100963,'Kristi',8470,'01-AUG-10',0);
    INSERT INTO datasampleA VALUES(1252467,100963,'Kristi',8473,'01-AUG-10',1);
    INSERT INTO datasampleA VALUES(119355,100989,'Christopher',8473,'18-JUN-01',1);
    in connectionB
    CREATE TABLE datasampleB (
              RID NUMBER(10) PRIMARY KEY,
             employeeNumber NUMBER(9),
              employeeName VARCHAR2(15),
             jobID VARCHAR2(10),
             job_date   DATE,
             end_date DATE
           )
    ;
    
    INSERT INTO datasampleB VALUES(121420,100171,'Jack',415,'03-JUN-99','05-DEC-99');
    INSERT INTO datasampleB VALUES(119590,100244,'Elizabeth',413,'13-SEP-99','13-SEP-99');
    INSERT INTO datasampleB VALUES(124847,100244,'Elizabeth',642,'30-DEC-01',NULL);
    INSERT INTO datasampleB VALUES(124252,100352,'Amy',7650,'25-MAY-08','03-SEP-10');
    INSERT INTO datasampleB VALUES(124253,100514,'Jonathan',646,'06-MAR-05','05-JUN-05');
    INSERT INTO datasampleB VALUES(116592,100526,'Ruben',646,'20-FEB-05',NULL);
    INSERT INTO datasampleB VALUES(116593,100526,'Ruben',7650,'20-FEB-05','29-AUG-10');
    INSERT INTO datasampleB VALUES(122273,100526,'Ruben',7650,'12-JAN-03','29-AUG-10');
    INSERT INTO datasampleB VALUES(121142,100615,'Peter',411,'21-JUN-99',NULL);
    INSERT INTO datasampleB VALUES(116594,100822,'Kathee',646,'20-MAR-05','21-OCT-06');
    INSERT INTO datasampleB VALUES(119354,100890,'Christopher',7650,'28-AUG-11','28-AUG-11');
    INSERT INTO datasampleB VALUES(417079,100890,'Christopher',7646,'28-AUG-11',NULL);
    INSERT INTO datasampleB VALUES(122128,100946,'Christopher',415,'11-MAR-02','27-JUN-02');
    INSERT INTO datasampleB VALUES(118382,100963,'Kristi',8477,'01-AUG-10','01-NOV-11');
    INSERT INTO datasampleB VALUES(831596,100963,'Kristi',8473,'01-AUG-10',NULL);
    INSERT INTO datasampleB VALUES(860841,100963,'Kristi',8477,'01-AUG-10','01-MAR-12');
    INSERT INTO datasampleB VALUES(1252467,100963,'Kristi',8477,'01-AUG-10','01-MAY-12');
    INSERT INTO datasampleB VALUES(119355,100989,'Christopher',410,'18-JUN-01',NULL);
    INSERT INTO datasampleB VALUES(119356,101141,'Jared',416,'12-SEP-99','30-JUN-00');
    OK, I worked on it, but I do not get good results when I do. I'm trying to compare data from two different connections to only return people with different numbers in "jobID".

    In English, that's what I want:
    All employees of A (which Active is 1), who are also in B (where End_date is NULL), where the JobID do not match.

    If it should return:
    100244
    100526
    100615
    100989

    But I was not able to find a way to get this result.

    Thank you!

    Michelle

    Try

    select *
      from datasamplea a
     inner join datasampleb b
        on a.employeenumber = b.employeenumber
     where a.active = 1
       and b.end_date is null
       and a.jobid != b.jobid;
    

    Published by: Paul Horth on 3 may 2012 05:26

  • Search for GPS data in LR3

    I add GPS data to digital photos. At the moment I arrived to IDImager, which shows a Google Map, I do drag and drop photos on the map, and then click Save to update the GPS coordinates in the image. Then when I open the image in LR3, the geocoded data is there. Granted it is quite quick and simple, but I prefer to be able to choose a location on a map in LR3 and added GPS coordinates. I could not yet find out how. Is this possible in LR3?

    LR not have built in support (yet), but here is a plugin that you might want to check.

    http://regex.info/blog/Lightroom-goodies/GPS

  • Search for files in a folder by date range?

    Trying to sort through a few photos in a folder, all confusing to form various phones and cameras and their Photos for Mac app development.

    Is there a way to search for specific dates in some way, via a recommended application or something please? I am busy making albums, for example Christmas 2002, 2003 Christmas and if you are looking for the picture files that are in the range say December 20, 2002-January 2, 2003. They are all in different folders for the moment on an external drive, so scattered everywhere.

    Can anyone help please?

    Thank you

    If you import the photos into the Photo app, they sort by date.

  • How can I tell the mail client to search for new mail on the server?

    How can I tell the mail client to search for new mail on the server?

    Within the Mail app and display the Inbox you can pull down on the list of e-mail using your finger and you should see a small reel spinning gear. Which indicates that his check new email.

    You can also go into the settings of e-mail and calendars Contacts and view the settings there. Examine the settings of "search for new data. If the Push is enabled, then messages will be pushed to you if the email provider supports this feature. You can also set your accounts to use Fetch and set the frequency, he's going to go out and look for new e-mail messages.

  • Search for photos by date?

    This seems an obvious thing to do, get my whole photo by date collection, for example date = 2015, but I can't find how to do it. Help, says there is a way, but does not show not what it is. Can someone help me?

    The photos are chronologically in the 'Photos' album, if you click the left arrow in the upper left corner of the screen, you can go to the display of "collections" instead of see 'moments', if you click on it again you will be taken to the view of "year".

    You can also type 2015 (for example) in the search field and find all your pictures with this date.

Maybe you are looking for