1. SQL Commands
Use the database found at http://goo.gl/NJDGdw
For each of the questions place a screenshot below as in the example.
i. How many customer records are there? What SQL command could you use to find
this out?
91 SELECT * FROM Customers
ii. How many customers are from Berlin or Mexico?
6
SELECT * FROM Customers
WHERE Country='Mexico'
OR Country='Germany'
AND City='Berlin'
iii. How many orders have a quantity greater than 40?
77
SELECT * FROM [OrderDetails]
WHERE Quantity > 40
iv. What is the quantity of order number 316?
5
SELECT Quantity FROM
[OrderDetails]
WHERE OrderDetailID=316
v. How many customers are from France and live in either Paris or Lyons?
2. 3
SELECT * FROM [Customers]
WHERE Country='France'
AND City='Paris'
OR City='Lyon'
vi. Which country do we find at the top of the records if we sort the customer data by
country?
Argentina
SELECT * FROM [Customers]
ORDER by Country
vii. Paste a copy of the SWL code used to delete Thomas Hardy from the customer table.
DELETE FROM [Customers]
WHERE CustomerName="Thomas Hardy"
viii. How many cities in the database end with the letter N?
11
SELECT * FROM [Customers]
WHERE Cities LIKE "%n"
ix. How many cities start with the letters J, K or L?
10
SELECT * FROM [Customers]
WHERE City LIKE "j%"
OR City LIKE "k%"
OR City LIKE "l%"
3. x. How many products are priced between 20 and 30?
14
SELECT * FROM [Products]
WHERE Price BETWEEN 20 AND
30
Continue with the tutorials at http://www.w3schools.com/sql/default.asp paying attention to SELECT,
FROM, WHERE, ORDER BY, GROUP BY, INNER JOIN, INSERT INTO, DELETE FROM, UPDATE,
CREATE DATABASE, CREATE TABLE, ALTER TABLE and ADD PRIMARY KEY