Writing SELECTs with Multiple Conditions - Exercise
Writing SELECTs with Multiple Conditions
Duration: 5 to 15 minutes.
In this exercise, you will practice writing
SELECT statements that filter records based on multiple conditions.
- Create a report that shows the first and last names and cities of employees from cities other than Seattle in the state of Washington.
- Create a report that shows the company name, contact title, city and country of all customers in Mexico or in any city in Spain except Madrid.
SELECT FirstName, LastName, City
WHERE Region = 'WA' AND City <> 'Seattle';
SELECT CompanyName, ContactTitle, City, Country
WHERE Country = 'Mexico' OR (Country = 'Spain'
AND City <> 'Madrid');