WST212 - Semester Test 1 - Submission Instructions - 2022
WST212 - Semester Test 1 - Submission Instructions - 2022
Instructions:
o All your code should be saved in a single R script, named ST1.R
o Both submissions are due on the 2nd of April at 12:30PM.
o Submission 1 consists of 27 marks, while Submission 2 consists of 8 marks.
Submission 1: Code
o Unlimited code submissions are allowed for the semester test
o The autograder consists of both visible and hidden tests. Results for visible tests
will be available shortly after submission. Results for hidden tests will be available
after publishing your marks.
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, submit your script with the correct
filename onto Gradescope.
Submission 2: Theory/Interpretation
o After completing the code submission, attempt the Theory/Interpretation
submission.
o Only one attempt is allowed, which must be completed in one sitting. Even if you
close the browser, the timer will continue counting down.
o You will have 20 minutes to complete this submission.
o If you accidentally submit your test but you still have time left, simply click on the
resubmit button to continue. The resubmit button will disappear when the timer
runs out.
Guidelines:
o A template, where students should fill their code in, has been provided on
ClickUP. Do not make any changes to the code that has been provided in the
template.
o For this Semester Test, six packages are required and loaded in the template,
while the necessary data has also been provided within the template.
© Copyright Reserved
Questions:
Question 1 (3 marks):
The accountant noticed a discrepancy in the invoice entries for shop
membership customers for the period of 5 January 2022 to 26 February 2022.
The accountant asked for your assistance to generate a report containing all
the information regarding invoices issued for the specified period. Order the
report by Customer Id. Make use of the following table:
customer_purchase_info. Save you query into the object named Q1
Question 2 (3 marks):
The marketing department would like to run a promotion targeted at
pensioners – 60 years or older. Write an SQL query that will generate a report
showing the qualifying customers’ full names, their contact information, date
of birth, and current age. Organize the report alphabetically according to the
customer full names. Make use of the following table: customer_info. Save
your query into the object named Q2
Question 3 (3 marks):
Management would like to address poor customer feedback and asked you to
create a report which groups the feedback into five categories: Excellent,
Good, Average, Poor, Terrible. The report should show the product line ID,
rating, and feedback category. Assign the new feedback category to a column
named Feedback. Order the report from highest to lowest rating. Make use of
the following table: customer_purchase_info. Save your query into the object
named Q3
© Copyright Reserved
• [4.5-6.5): Average
• [3-4.5): Poor
• [0-3): Terrible
Question 4 (3 marks):
The finance department asked you to create a report which shows the number
of customers per payment method. Limit the report to only show payment
methods used by more than 320 customers. Organize the report from highest
to lowest. Make use of the following table: customer_purchase_info. Save your
query into the object named Q4
Question 5 (3 marks):
Unfortunately, some employee records have gone missing. To salvage the
employee records, the HR manager asked you to compile a report that will aid
the process of updating the records. The HR manager mentioned that some
employees are also customers at TimeSuperstores. Although not all employees
are customers at TimeSuperstores, the HR manager asked to include the
details of those employees as well. Write an SQL query displaying the
employee id, employee full name, contact information, address, gender, and
birth date. Make use of the following tables: employee_purchase_info and
customer_info. Save your query into the object named Q5
Question 6 (8 marks):
The finance department would like a list of total sales per branch, broken
down by product item group.
Question 6a (4 marks):
Before investigating the report on the total sales per branch, the finance
department wants to view the total purchase amount made by each
customer. Write an SQL query that will generate a report showing the
Customer_ID, Invoice_ID, and total invoice amount per customer. Assign
the total invoice amount per customer to a column named
Customer_Total. The report should only display complete information.
Organize the report from highest to lowest total purchase. Make use of
the following tables: customer_purchase_info and
customer_purchase_ctc. Save your query into the object named Q6a
© Copyright Reserved
Question 6b (4 marks):
Follow the same logic from Question 6a and write an SQL query to
display the total sales per branch, broken down by product item group.
Include the product item group description such that the finance
department can communicate efficiently with the other departments.
The final report should display the Branch name, Product id, product
item description, and the total sales. Order the report by branch name
and product id. Make use of the following tables:
customer_purchase_info, customer_purchase_ctc, and
product_description. Save your query into the object named Q6b
Question 7 (4 marks):
Your manager asked you to compile a report of only those customer
purchases where the profit made per purchase is R20 or more. Write an SQL
query that produces a report that displays the Customer_Id, Invoice_ID, Total
purchase value, cost of goods sold (cogs), and the Profit made. The report
should be displayed from lowest to highest profit. Make use of the following
tables: customer_purchase_info and product_sales. Save your query into the
object named Q7
© Copyright Reserved