Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2009
    Posts
    6

    Unanswered: Help with query - tearing hear out !!

    I would really appreciate some help with the following: SQL SVR 2008

    TABLE 1

    CODE NAME
    JS John Smith
    LJ Louise Jobes
    PL Paul Lucas

    TABLE 2

    CODE STATUS FROM TO
    JS JOB1 09:00 10:00
    JS JOB2 13:00 15:00
    PL JOB94 09:00 12:00

    I am trying to produce a select query that will provide a list of all names from table one that are not doing anything. So I need to compare DATETIME() with the entries in TABLE 2 and return all the names that are not currently doing anything.

    Thank you very much for any assistance.

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    The easiest way to do this is to find all the people doing something, and then return all people that do not appear in this list. that way, you break the problem down in to two parts and you can completely ignore table 1 for the first part.

    Do you fancy having a stab at that first part of SQL? When you post that, please also post the datatypes for FROM and TO. We can then tweak it to solve the problem.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Nov 2009
    Posts
    6
    Many thanks for your advice - I have broken this down as you suggested and used MINUS to get the result I was looking for. Many thanks

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Lol - good job!
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

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