Matthew Dusterhoft Matthew Dusterhoft - 1 month ago 4x
SQL Question

SQL Query - Limit Results

I have query that contains a departmentID. I want the results to not be returned for 2 or 3 departments out of about 25.

select i.personID,, c.departmentID, se.sectionID
from individual i
INNER JOIN Section se ON se.teacherPersonID = i.personID
INNER JOIN Course c ON c.courseID = se.courseID
INNER JOIN Calendar cal ON cal.calendarID = c.calendarID and c.calendarID = 32 INNER JOIN SchoolYear sy on sy.endyear = cal.endyear and = 1
INNER JOIN activeTrial at ON at.trialID = se.trialID
inner join contact con on con.personID = i.personID
Where c.departmentID is not NULL
order by c.departmentID


Making the assumption that you don't want data to show for department ID's 4,5, and 6:

Where c.departmentID is not NULL AND c.departmentID not in {4, 5, 6}