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

WST 212 Practical 4 -SQL JOINS

Instructions:
o Complete the questions which follow and save all your code in a single R script, named
Practical4.R o

Submission 1: Code 
o Multiple code submissions are allowed and your autograded results will be available shortly
after each submission.
o Ensure all variables are named correctly, as incorrectly named variables will not be awarded any
marks. (Remember variable names are case sensitive.)
o Ensure your code does not consist of any syntax errors. If your code produces errors when run,
the autograder will not be able to mark it.
o Any code commented out (code is commented out when # is typed in front of it) will be
considered rough work and will not be marked.
o Once you have completed your submission, ensure the file is submitted on Gradescope, with
the correct file name. The autograder will only be able to grade your submission if you use the
correct filename.

Guidelines:
o The datasets required to complete the practical have been provided on ClickUP.
o A template that can be used for this assignment has been provided on ClickUP.
o Remember to assign your code to the variables indicated in this document.
Questions:

1.) Consider the Orion database. The head of the Sales Department wants to know how many
of each product was sold between 2011 and 2012. The report should include the product
ID, the product name, and the total quantity ordered. The data that you need can be found
in the listed columns of the following tables:

• orion_product_dim
• orion.order_fact

Order your report by the total quantity ordered, and by the product name for those products
with the same quantity.

2.) Consider the Orion database. Join orion_sales and orion_employee_addresses on


Employee_ID to create a report showing the names and cities of all female Orion
employees. If an employee is in the Sales Department, also show the job title. Present the
report in alphabetical order by city, job title, and name. (Use the Employee_Name column)

3.) Consider the Orion database. Join the orion_order_fact and orion_product_dim tables to
determine whether there are any items in the product dimension table that have never been
sold.

4.) Consider the Orion database. Create a report showing Orion catalogue and Internet
customers residing in the U.S. or Australia who purchased foreign-manufactured products
(that is, a product that was not manufactured in their country of residence). The report
should display the customers’ names and the number of foreign purchases made. Present
the information so that those with the largest number of purchases appear at the top of the
report, and customers who have the same number of purchases are displayed in
alphabetical order. Employee_ID 99999999 is a dummy ID that can be used to identify
catalogue and Internet orders. The data that you need can be found in the listed columns of
the following tables: orion_product_dim, orion_order_fact and orion_customer.

5.) Consider the Ultimate database. Write a query that displays the first name, email address,
suburb name and city name of all employees that have an email address registered to
either the ‘ymail’ or ‘shaimail’ domains.

6.) Consider the Ultimate database. Write a report that displays the following (in this order):

• Flat unit number


• Building name
• Suburb name
• City name

You might also like