Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2014
    Posts
    1

    Unanswered: SQL vlookup - comparison

    Hi I hope some one can help, I am new to SQL Oracle. I have table_A where I have a list of jobs and time for when those jobs have been assigned, I am trying to find out the number of jobs that have not been assigned but are then assigned later on during the future date. So was going to use a select statement to display all jobs that have been assigned (lable as LIST 1) and then obtain another list (List 2) to show all the jobs that have not been assigned, i would then do a comparison from List 2 with List 1 and if it is in List 1 then that would indicate that at some point that job has been assigned. So for example:-

    List 1:-
    Date Job No Allocated
    02/09/2014 09:00 11 Yes
    02/09/2014 09:00 12 Yes
    02/09/2014 10:00 13 Yes
    02/09/2014 14:00 14 Yes

    List 2:-
    Date Job No Allocated
    02/09/2014 09:00 5 No
    02/09/2014 09:00 7 No
    02/09/2014 09:00 14 No

    So from this you can see Job No 14 was not assigned in the morning but later on that afternoon it was assigned, which is what I would want it to out put for me :-

    Output list :-
    Date Job No Assigned
    02/09/2014 09:00 14 02/09/2014 14:00

    ANy help would be greatly appreciated, I have looked into JOIN, MINUS, EXCEPT and have not been able to output what I want. This can be done with vlookup but I don't know what the equivalent for it in SQL, google says JOIN but I just can't seem to get that to work, thanks.

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Wink

    Quote Originally Posted by Coffe View Post
    Hi I hope . . .
    . . .Any help would be greatly appreciated, I have looked into JOIN, MINUS, EXCEPT and have not been able to output what I want. . . .
    Try:
    Code:
    SELECT L2.Date, L2.Jobno, L1.Date
      FROM List2 L2 INNER JOIN List1 L1 
        ON L1.Jobno = L2.Jobno
     WHERE L2.Allocated = 'No'
       AND L1.Allocated = 'Yes';
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •