'How to call lines that only have one record in a table?
I have a table that looks like this;
| Job | Order | Status |
|---|---|---|
| 101 | 212 | Error |
| 101 | 212 | Complete |
| 202 | 321 | Error |
| 202 | 321 | Complete |
| 303 | 404 | Error |
| 303 | 404 | Complete |
| 444 | 505 | Error |
| 535 | 667 | Error |
I need to only pull the JOB# that are showing one error line (not an error and complete). The only thing I want to call are
| Job | Order | Status |
|---|---|---|
| 444 | 505 | Error |
| 535 | 667 | Error |
Solution 1:[1]
Something like the following:
select Job, Order, Status
from t
where t.status = 'Error'
and not exists (
select * from t t2
where t2.Job = t.Job and t2.Order = t.Order and t2.Status != t.status
);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Stu |
