Figure out which rows DO NOT contain a value

I have a query that shows me a result set of documents that are attached to Orders within my system.  I need to be able to filter this result set and base the logic to see which ones DO NOT have a DocTypeID of 'WorkTick'

What I'm attempting to do is figure out which Orders do not have a work ticket associated basically this way I can create a report to show which orders don't have tickets but there are various document types so I'm a little confused on the best and most efficient means of doing so?  Its almost like I have to build the result set, and THEN loop through that result set to see which ones do or do not.  At least thats what I see at first glance.

Any help is VERY much appreciated and I will promptly respond and accept an answer

SELECT * FROM eDocData ORDER BY OrderNum DESC

The result set looks like so:

OrderNum      DocTypeID
87673                       NULL
87651                       DispTick
87625                       NULL
87622                       NULL
87550                       DispTick
87549                       WorkTick
87549                       DispTick
87546                      WorkTick
87546                      DispTick
87541                      NULL
LVL 2
chrisryhalAsked:
Who is Participating?
 
liijaConnect With a Mentor Commented:
Can it be this simple?

SELECT * FROM eDocData
WHERE DocTypeID <> 'WorkTick'
 OR DocTypeID IS NULL
0
 
britpopfan74Connect With a Mentor Commented:
If I'm understanding correctly, only those with 'WorkTick' are valid work orders and all others are not?

If so, it could just be:

SELECT * FROM eDocData
WHERE DocTypeID = 'WorkTick'
ORDER BY OrderNum DESC
0
 
Simone BConnect With a Mentor Senior E-Commerce AnalystCommented:
You could try a subquery:

Select * from eDocData where OrderNum not in
(Select OrderNum from eDocData where doctypeid = 'WorkTick')
0
 
chrisryhalAuthor Commented:
I feel really dumb, but yes it was that easy (GRIN)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.