Professional Documents
Culture Documents
BUS 464 Assignment 2
BUS 464 Assignment 2
● https://www.w3schools.com/sql/trysql.asp?filename=trysql
Execute the SQL statements below and observe the result. Try to guess what each SQL
statement does and explain it . Also mention how many records each SQL statement
generates
This SQL statement is going into the database and collecting all the data information
from the ‘’Customers” table and showing it in a single table. This table shows all the
information we have about customers. There are 91 records.
This SQL statement is only going to list out the name of every country that each
customer is from. There will be one country for every customer, regardless of if there
are multiple customers from the same country. There are 91 records.
Q3 SELECT DISTINCT(Country) FROM Customers
This SQL statement is going to list the different country names once. However, if
there are multiple customers form the same country then that country will only be
listed once. There are 21 records.
Q4 SELECT COUNT(CustomerID), Country
FROM Customers
GROUP BY Country
This SQL statement is going to list out all the different countries that customers are
from in one column and in another column there will be the total number of customers
that are from that given country. There are 21 records.
This SQL statement is trying to list out all the different countries that customers are
from in one column and in another column there will be the total number of customers
that are from that given country. Additionally it is trying to list the data by the number
of customers in ascending order. However, there is an error in this statement and
therefore 0 records shown.
Q6 SELECT * FROM Customers, Orders
This SQL statement shows all the customer information for every order in the
database. There are 196 records.
Part 2 (7 marks)
Consider the Northwind sample database posted available at
https://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all
(Links to an external site.)
Write the following Queries:
Q7 (1 mark) List all cities from the customer table (we want to know what cities are there in
the customer table). How many cities are there?
Q8 (1 mark) List the customers who are from Germany but not from city Brandenburg
Q10 (2 marks) List all the product names which are ordered for quantity of more than 10. The
result set (resulting table) has to include the following column (Note: just list unique product
names . That means do not repeat a product name multiple times) ProductName, Quantity
Q11 (2 marks) List all the product names which are ordered for quantity of more than 10 by
customers from USA the result set has to include the following columns CustomerName,
ProductName, Quantity
SELECT CustomerName, ProductName, Quantity
FROM OrderDetails, Products, Customers
WHERE OrderDetails.ProductID = Products.ProductID
AND Quantity > 10
AND Country = 'USA';
There are 5018 records.