1

I have a table with three columns:

(JobNo, ProgramId & Status)

JobNo have many ProgramId and each ProgramId has Status

I need to retrieve only those JobNo where all the ProgramId for the same JobNo have Status = "delivered".

From the given image only JobNo (1&4) should be output as only JobNo (1&4) the ProgramId's Status="delivered".

Click here to see table

2
  • You should edit your question and provide sample data and desired results. The explanation is dense and hard to follow. Commented Mar 19, 2016 at 15:27
  • Please click on the above link to see the sample table. Commented Mar 19, 2016 at 15:28

2 Answers 2

1

Try something like this (not tested):

SELECT      JobNo
FROM        MyTable
GROUP BY    JobNo
HAVING      SUM(IIF(Status = 'Delivered', 0 , 1)) = 0
Sign up to request clarification or add additional context in comments.

1 Comment

Thanku sir.Got what i wanted.
1

Your question suggests group by with having:

select jobid
from t
group by jobid
having min(status) = max(status) and min(status) = 'delivered';

1 Comment

Thanku sir.Got what i wanted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.