Solved

Figure out which rows DO NOT contain a value

Posted on 2013-01-25
4
220 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 167 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 167 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 166 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

724 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