I need help refining the WHERE clause on a query for the table below:
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
I need to exclude all the ‘All Locations’ records, but keep the ‘All Locations’ records where the Role is Manager. To get the desired result:
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
I feel that the query below would exclude all the All Locations records, including the Manager ones.
SELECT * FROM Table
WHERE (Location <> 'All Locations' AND Role <> 'Manager')
You should use OR instead of AND