[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Figure out which rows DO NOT contain a value

Posted on 2013-01-25
4
Medium Priority
?
222 Views
Last Modified: 2013-01-25
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
0
Comment
Question by:chrisryhal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 6

Accepted Solution

by:
liija earned 668 total points
ID: 38820286
Can it be this simple?

SELECT * FROM eDocData
WHERE DocTypeID <> 'WorkTick'
 OR DocTypeID IS NULL
0
 

Assisted Solution

by:britpopfan74
britpopfan74 earned 668 total points
ID: 38820289
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
 
LVL 11

Assisted Solution

by:Simone B
Simone B earned 664 total points
ID: 38820290
You could try a subquery:

Select * from eDocData where OrderNum not in
(Select OrderNum from eDocData where doctypeid = 'WorkTick')
0
 
LVL 2

Author Closing Comment

by:chrisryhal
ID: 38820435
I feel really dumb, but yes it was that easy (GRIN)
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question