如何正确写出复杂的逻辑条件?

How to write a complex logical condition correctly?

我在 Access 中有 2 个表:FACULTY 和 SGROUP。

教师:

SGROUP:

我需要在一个条件下输出SGROUP.GrpNo和FACULTY.FacNo ...

IIF (FACULTY.Fund> 20000 AND SGROUP.Rating> 10) OR (faculty group from building 6 AND SGROUP.Rating <70) OR (faculty group from building 5 AND SGROUP.Rating> 40)

我明白他们想从我这里得到什么,但我完全不明白如何在 sql 上建立一个复杂的条件来解决这个问题。

P.S: 剩下的数据库表。

部门:

老师:

主题:

房间:

讲座:

给你,我的朋友:

select 
    *
from 
    lecture l
inner join
    teacher t on t.tchno = l.tchno
inner join 
    department d on d.depno = t.depno
inner join 
    faculty f on f.facno = d.facno
inner join 
    sgroup sg on sg.groupno = l.sbjno
inner join 
    room r on r.roomno = l.roomno
where     
    (f.Fund> 20000 AND sg.Rating> 10) OR 
    (r.Building = 6 AND sg.Rating <70) OR 
    (r.Building 5 AND sg.Rating> 40)