SQL Assessment Questions With Hints Repaired
SQL Assessment Questions With Hints Repaired
SQL Assessment Questions With Hints Repaired
Assessment: SQL
This assessment evaluates your knowledge and skills learnt in the following modules:
● Introduction to SQL
● Intermediate SQL
● SQL Server or PostgreSQL (whichever applicable)
Assessment Directions:
● You have 2 hours to complete this test.
● There are 2 sections with 100 total points. The performance point scale is as follows:
80 - 100 60 - 79 0 - 59
Section A - MCQ / 20
Section B - Case / 80
2. Which statement is used to delete all rows in a table without having the ( )
action logged?
(a) DELETE
(b) REMOVE
(c) DROP
(d) TRUNCATE
https://www.coursehero.com/file/107820248/SQL-Assessment-Questions-with-hints-Repaireddocx/
Participant Name: ___________________________
9. Find the cities name with the condition and temperature from table ( )
'whether' where condition = sunny or cloudy but temperature >= 60.
https://www.coursehero.com/file/107820248/SQL-Assessment-Questions-with-hints-Repaireddocx/
Participant Name: ___________________________
For PostgreSQL, please download the sql to install the database from:
https://github.com/pthom/northwind_psql
For SQL Server, please download the sql to install the database from:
https://github.com/microsoft/sql-server-samples/tree/master/samples/databases/northwind-
pubs
https://www.coursehero.com/file/107820248/SQL-Assessment-Questions-with-hints-Repaireddocx/
Participant Name: ___________________________
https://www.coursehero.com/file/107820248/SQL-Assessment-Questions-with-hints-Repaireddocx/
Participant Name: ___________________________
Tasks
1. Write a query to get current Product list (Product ID and name). (1 point) Hint:
discontinued = 0
2. Write a query to get Product list (name, unit price) where products cost between $15 and
$25. (1 point) Hint: discontinued = 0
3. Write a query to get Product list (name, units on order, units in stock) of stock is less than
the quantity on order. (3 points) Hint: discontinued = 0
4. Select all product names, unit price and the supplier region that don’t have suppliers
from the USA region. (3 points) Hint: Inner Join
5. Get all customer names that live in the same city as the employees. (3 points) Hint:
subquery
6. Get the number of customers living in each country Where the number of residents is
greater than 10 and sort the countries in descending order. (3 points) Hint: Group by …
Having…
7. Get the number of employees who have been working more than 5 year in the company.
(3 points) Hint: date_part(), age()
8. When was the first employee hired in the company? (3 points) Hint: Limit
9. Display the Customer Name (ContactName) and the number of orders ordered by this
customer, for customers living in the UK. Arrange the result based on the number of
orders from the greatest to the lowest. (5 points) Hint: COUNT(orders.order_id)
10. Get the number of orders for each displayed Customer Name (ContactName) living in
the USA and restrict the result for those customers who ordered more than five orders.
Label any un-named column(s) with a meaningful name(s) (5 points) Hint: WHERE,
AND, GROUP BY, HAVING
11. Get the total quantity ordered for each displayed product name with unit price higher
than 30. Restrict the result for those products having total ordered quantity in the range
between 1000 and 1500. Label any un-named column(s) with a meaningful name(s).
(5 points) Hint: WHERE, AND, GROUP BY, HAVING
12. For each of the following countries (USA, Italy and France), display the country name in
addition to the number of suppliers living in this country and having a fax number. Sort
the result by the country name in a descending order and give a meaningful name(s) for
any un-named column(s). (5 points) Hint: AND fax is NOT NULL
13. Display the first name, job title and the city of all employees not working as Sales
Managers and living in the same city as the employee with first name: Michael. Sort
https://www.coursehero.com/file/107820248/SQL-Assessment-Questions-with-hints-Repaireddocx/
Participant Name: ___________________________
the result by the first name of the employees in an ascending order. (8 points) Hint:
Subquery city from employees
FROM employees
FROM employees
14. Display the first name, job title and the country of all employees working as Sales
Representatives and living in the same country as the manager (Note: the manager
is the person that doesn’t report to anyone). Sort the result by the first name of the
employees in a descending order. (8 points) Hint: WHERE reports_to IS NULL
FROM employees
FROM employees
15. Display the first name, address and the hire date of all employees having an address
containing 2 and who were hired before the employee with first name: Steven. Sort the
result by the first name of the employees in an ascending order. (8 points) Hint: LIKE
FROM employees
SELECT hire_date
FROM employees
WHERE first_name='Steven'
https://www.coursehero.com/file/107820248/SQL-Assessment-Questions-with-hints-Repaireddocx/
Participant Name: ___________________________
ORDER BY first_name;
16. Display the first name, country and the birth date of all employees who were born before
1958 and are working in the same country as the employee with first name: Laura. Sort
the result by the first name of the employees in an ascending order. (8 points)
FROM employees
WHERE EXTRACT( YEAR from birth_date) < 1958 and country IN (SELECT country
FROM employees
ORDER BY first_name;
17. For each displayed country name, show how many products were supplied by suppliers
who have got a fax number. Restrict the result for those countries having less than five
supplied products. Label any un-named column(s) by a meaningful name(s). (8 points)
https://www.coursehero.com/file/107820248/SQL-Assessment-Questions-with-hints-Repaireddocx/
Powered by TCPDF (www.tcpdf.org)