SQL for SELECT with
criteria
exercises:
SELECT ProductName,
SupplierID,
UnitPrice
FROM Products
ORDER BY ProductName;
SELECT ProductName,
SupplierID,
UnitPrice
FROM Products
WHERE UnitPrice <= 10
ORDER BY ProductName;
SELECT ProductName,
SupplierID,
UnitPrice
FROM Products
WHERE UnitPrice BETWEEN 10
AND 20
ORDER BY ProductName;
SELECT ProductName,
SupplierID,
UnitPrice
FROM Products
WHERE ProductName LIKE
"*Choc*"
OR ProductName LIKE
"*Schok*"
ORDER BY ProductName;
SELECT CompanyName,
ContactName, Phone, Fax, Region
FROM Customers
WHERE Region is not null
ORDER BY CompanyName;
To
find
customers not assigned to a region (60 customers):
SELECT CompanyName,
ContactName, Phone, Fax
FROM Customers
WHERE Region is null
ORDER BY CompanyName;
NOTE: No need to include region in the select list – we know there is no value for region in this query.