我需要帮助改进对下表查询的WHERE子句:满足WHERE条件 - T-SQL
Key | Name | Role | Location
111 | Bob | Manager | All Locations
222 | Jim | Manager | All Locations
333 | Tim | Sales | Washington
444 | Roy | Sales | New York
555 | Lee | Sales | All Locations
666 | Gus | Sales | All Locations
777 | Joe | Admin | All Locations
888 | Jen | Admin | New York
我需要排除所有的“所有地点”的记录,但保留“所有位置的记录,其中角色是经理。为了得到理想的效果:
Key | Name | Role | Location
111 | Bob | Manager | All Locations
222 | Jim | Manager | All Locations
333 | Tim | Sales | Washington
444 | Roy | Sales | New York
888 | Jen | Admin | New York
我觉得下面的查询会排除所有的位置记录,包括管理者的记录。
SELECT * FROM Table
WHERE (Location <> 'All Locations' AND Role <> 'Manager')