Using the WHERE clause to check for greater or less than - Exercise

Contact Us or call 1-877-932-8228
Using the WHERE clause to check for greater or less than - Exercise

Using the WHERE clause to check for greater or less than

Duration: 5 to 15 minutes.

In this exercise, you will practice using the WHERE clause to check for values greater than or less than a specified value.

  1. Create a report that shows the employee id, order id, customer id, required date, and shipped date of all orders that were shipped later than they were required.
  2. Create a report that shows the city, company name, and contact name of all customers who are in cities that begin with "A" or "B."
  3. Create a report that shows all orders that have a freight cost of more than $500.00.
  4. Create a report that shows the product name, units in stock, units on order, and reorder level of all products that are up for reorder.

Solution:

SimpleSelects/Solutions/GreaterThanLessThan.sql
SELECT EmployeeID, OrderID, CustomerID, RequiredDate, ShippedDate
FROM Orders
WHERE ShippedDate > RequiredDate;

SELECT City, CompanyName, ContactName
FROM Customers
WHERE City < 'C';

SELECT OrderID, OrderDate, Freight
FROM Orders
WHERE Freight > 500;

SELECT ProductName, UnitsInStock, UnitsOnOrder, ReorderLevel
FROM Products
WHERE UnitsInStock <= ReorderLevel;
Next