TEC C TEC C - 3 years ago 54
SQL Question

SQL Show groups where record is missing

I have two columns that I am looking at one for job order and one for operation number for each job order there is a series of operations 1-4 so it would look something like.

Job Order Operation
------------------------
00023 1
00023 2
00023 3
00023 4
00024 1
00024 2
00024 3
00024 4
00025 1
00025 2
00025 3
00025 4
00026 2
00026 3
00026 4


I would like to show all Job orders that are missing Operation 1. In this example since they would be grouped I would only see one instance of job order 00026 since that is the only job order missing operation 1.
The desired out put Would look like

Job Order
---------------
00026

Answer Source
select Job_Order 
from your_table
group by Job_Order 
having min(Operation) > 1
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download