Nested and complicated select statement

Posted by Selase on Stack Overflow See other posts from Stack Overflow or by Selase
Published on 2011-01-11T17:49:37Z Indexed on 2011/01/11 17:53 UTC
Read the original article Hit count: 204

What i want to do here is simple...display an ivestigators ID and him corresponding name... That can be easily done from the users table by selecting based on the user type. However i want to select only some type of investigators. The analogy here is investigators are assigned to an exhibit for them to investigate. One investigator can be assigned to a maximum of 3 cases only. Now during the assigning of investigators, i want to write a select statement that would retrieve only investigatorID's that have been assigned to less than or equal to 2 cases. I have included exhibit and users table that shows sample data below. alt text

alt text

Now i sort of have an idea that i will have to first of all pick out all the investigators by their ID from the users list and then filter them through the exhibit table by dropping those assigned to 3 cases and leaving just those with two cases. then afterwards i use this IDs to select the Investigators name.

the big questions is how do i write the statement??

© Stack Overflow or respective owner

Related posts about c#

Related posts about database