I have a problem that I can't wrap my head around, in that case. Maybe someone will have an idea.
My table has the following structure:
MYJOBS
JobNum int,
Sequence int,
Completed bit (or bool - whatever pSQL uses)
The primary key is JobNum and Sequence
It is populated with data like:
| JobNum | Sequence | Completed |
| 1 |
1 |
1 |
| 1 |
3 |
0 |
| 1 |
4 |
0 |
| 2 |
54 |
1 |
| 2 |
75 |
1 |
| 2 |
80 |
0 |
The query I want to use is:
SELECT t1.JobNum, t1.Sequence,
(SELECT TOP 1 Completed
FROM myJobs
WHERE JobNum = t1.JobNum
AND Sequence = t1.Sequence
AND Completed = 0
ORDER BY Sequence) AS CurrentSequence
FROM myJobs t1
ORDER BY t1.JobNum, t1.Sequence
It's a simple task. In one query return the jobnum, sequence, and the first incompleted sequence related to the record. Is it possible?
Thanks for your quick responses. I'm surprised this forum is so active for a depricated product!
Doug