我需要帮助改进下表查询中的 WHERE 子句:
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')