Topic
2 replies Latest Post - ‏2014-09-12T20:10:52Z by mwking
mwking
mwking
6 Posts
ACCEPTED ANSWER

Pinned topic Trying to list orders where a specific part is NOT present

‏2013-04-01T20:58:30Z |
Fairly new to SQLand need some help.
Using a typical Order Header table and Order Detail table that are linked by Order number. I need to identify orders where the part # = 'LABOR' is not present.
Is there an SQL construct that will allow me to come up with an answer set of the Orders that do not contain the part 'LABOR' in 1 pass, or will I have to do 2 or more passes?
Updated on 2013-04-04T14:53:36Z at 2013-04-04T14:53:36Z by krmilligan
  • krmilligan
    krmilligan
    446 Posts
    ACCEPTED ANSWER

    Re: Trying to list orders where a specific part is NOT present

    ‏2013-04-04T14:53:36Z  in response to mwking
    Don't fully understand your database, but how about something like the following:

    SELECT ordnum FROM ordhdr
    WHERE ordnum NOT IN (SELECT DISTINCT ordnum FROM orddtl WHERE part#='LABOR')
    • mwking
      mwking
      6 Posts
      ACCEPTED ANSWER

      Re: Trying to list orders where a specific part is NOT present

      ‏2014-09-12T20:10:52Z  in response to krmilligan

      Sorry for the long, long delay in responding.   Your fix seems to do what I need.   Thank you very much.