0% found this document useful (0 votes)
10 views5 pages

SQL Tutorial: Subqueries and Queries

This document is a tutorial for SQL queries with specific instructions for using subqueries and accessing a database. It includes five questions that require writing SQL queries to retrieve various data from the database, with expected outcomes for each query. The tutorial emphasizes the importance of using subqueries and provides a link to the database for practice.

Uploaded by

mk365org
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views5 pages

SQL Tutorial: Subqueries and Queries

This document is a tutorial for SQL queries with specific instructions for using subqueries and accessing a database. It includes five questions that require writing SQL queries to retrieve various data from the database, with expected outcomes for each query. The tutorial emphasizes the importance of using subqueries and provides a link to the database for practice.

Uploaded by

mk365org
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

TUTORIAL 3

7 APRIL 2025

INSTRUCTIONS:

1. Use subqueries for all answers except Question 1. Marks will not be awarded for code without a
subquery.
2. Watch the “How to run the Database” tutorial video.
3. Copy the link into your browser to access the Database: [Link]
samples/blob/master/samples/databases/northwind-pubs/[Link]
Question 1 (Marks: 3)
Write a union query to display the company names from both the Suppliers and Shippers tables.

Expected Outcome:

Question 2 (Marks: 4)

Write a query to determine if there are Products that have never been ordered. The query should
display the ProductName of the products that have not been ordered.
Include a comment under your query with the answer: "YES" or "NO" to the question.
Question 3 (Marks: 3)
Write an SQL query to display the order ID, freight cost, and the average freight cost.

NB: Expected Outcome returns 830 Records


Sample Results:

Question 4 (Marks: 5)
Write a query to calculate the average number of orders per customer for each country.
The query should display the customer ID, shipping country, and the average number of orders.

NB: Expected Outcome returns 89 Records


Sample Results:
Question 5 (Marks: 3)
Write a query to retrieve the details of employees who have participated in orders and whose first name
contains the letter "a." The query should display the employee's ID, first name, order ID, product name,
and order date.

NB: Expected Outcome returns 1825 Records


Sample Results:

END OF TUTORIAL

You might also like