CSC 105 - Assignment 2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

CSC 105 (SPRING 2023)

University of Victoria

ASSIGNMENT 02
Due Date: 11.59 pm Friday, 24th February 2023

Note: This assignment must be done individually. University policies for academic integrity will
be followed.

Learning Goals:

In this assignment, you will

• Review a database given to you.


• Create and run queries on the given database

ASSIGNMENT DESCRIPTION:

You have been given a Microsoft Access database (company.accdb) which contains data pertaining to customers and
the orders they placed for selected products. Your task is to open this database, understand its content and structure
(have a look at the relationships) and then write SQL queries.

YOUR TASKS:
Your task is to write 10 SQL queries as listed below. Carefully read the instructions on what to submit and how to
write your answers in this document's “Deliverable” section.

QUERIES
Write an SQL that will achieve each of the following tasks. When the names of the columns have not been specified,
show all the columns in the affected tables. No single query from the list will return an empty resultset:
Query 1. Display the list of all customers in the database.
Query 2. Display the customerNumber and customerName of all customers from the USA.
Query 3. Display all customers from the USA whose name contains the word “toy”.
Query 4. Display the total count of orders in the orders table. The resulting column should be labelled
“Total”.
Query 5. Display both the lowest and highest price in OrderDetails. The resulting columns should be labelled
LowestPrice and HighestPrice, respectively.
Query 6. Display the total number of orders that were made between April 1st and June 30th, 2003.
Query 7. Display all orders that were shipped before the required date.
Query 8. Display customerName and customerNumber of all customers from Spain who have orders that
have not been marked as shipped.
Query 9. Display the customerNumber, customerName, and number of orders for 2 customers who placed
the most orders.
Query 10. Display the list of products (that is, customerNumber, customerName, productName, and the Total
Order Price (that is quantity * price)) that were placed by a customer with customerNumber 114.
DELIVERABLE:

Write all your answer in a text file named “assignment02.txt” and submit in Brightspace before the deadline. Your
submission must meet the following criteria

1) Clearly indicate the query number that your written query is answering.
2) Write the query in a clearly understandable manner. DO NOT write everything in one long line. A good
example of a well-written query that is easier to read is as follows

SELECT Accounts.ACCOUNT_NUMBER, Customers.NAME, Customers.ADDRESS


FROM Accounts JOIN Customers
ON Accounts.ACCOUNT_NUMBER = Customers.ACCOUNT_NUMBER
WHERE
(Accounts.BALANCE > 10000
AND
Customers.CITY = “Toronto”)

OR

(Accounts.BALANCE > 50000


AND
Customers.CITY = “Vancouver”)

ORDER BY Customers.NAME;

Note the use of capital letters for SQL keywords and the way the query is spaced.

3) DO NOT include the resulting tables from your queries

If there is any confusion in understanding your answer, the marker will award a lower mark or may even deem the
submission unmarkable.

Note that Brightspace is enabled to allow you to submit multiple times. It is recommended that you submit your
work often. We will mark the latest submitted file.

GRADING:

All queries have the same weight. Each query is 2 Marks. This assignment is worth 20 marks.

You might also like