我需要幫助改進對下表查詢的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')