我有包含departmentID的查詢。我希望結果不予退還2個或3系出約25SQL查詢 - 限制結果
select i.personID, c.name, 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 sy.active = 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
在SQL Server,你可以使用 「TOP(N)」 的功能,如: SELECT TOP(N)* FROM表 其中N是您想要的行數。在Oracle中,你必須添加「WHERE RowNum
rualmar
你能澄清一些嗎?你想要的結果是「不返回2-3分」?你有這些部門或其他數據你想刪除它們的ID? –
爲什麼不試試'Where IsNull(c.departmentID,-1)不在(-1,2,3,5)'中? – AVK