Using the WHERE clause to check for equality or inequality - Exercise

Contact Us or call 1-877-932-8228
Using the WHERE clause to check for equality or inequality - Exercise

Using the WHERE clause to check for equality or inequality

Duration: 5 to 15 minutes.

In this exercise, you will practice using the WHERE clause to check for equality and inequality.

  1. Create a report showing all the company names and contact names of Northwind's customers in Buenos Aires.
  2. Create a report showing the product name, unit price and quantity per unit of all products that are out of stock.
  3. Create a report showing the order date, shipped date, customer id, and freight of all orders placed on May 19, 1997.
    • Oracle users will have to use following date format: 'dd-mmm-yyyy' (e.g, '19-May-1997').
    • MySQL users will have to use following date format: 'yyyy-mm-dd' (e.g, '1997-05-19').
  4. Create a report showing the first name, last name, and country of all employees not in the United States.

Solution:

SimpleSelects/Solutions/EqualityAndInequality.sql
SELECT CompanyName, ContactName
FROM Customers
WHERE City = 'Buenos Aires';

SELECT ProductName, UnitPrice, QuantityPerUnit
FROM Products
WHERE UnitsInStock=0;

/******************************
For the third problem, both of the solutions below will work in SQL Server

Oracle Solution
******************************/
SELECT OrderDate, ShippedDate, CustomerID, Freight
FROM Orders
WHERE OrderDate = '19-May-1997';

/******************************
MySQL Solution
******************************/
SELECT OrderDate, ShippedDate, CustomerID, Freight
FROM Orders
WHERE OrderDate = '1997-05-19';

SELECT FirstName, LastName, Country
FROM Employees
WHERE Country <> 'USA';
Next