Write a SQL query to retrieve the top 5 salespeople with the highest total sales amount for the month of January 2023

FIT 9132 Week 10

Quiz
•
Computers
•
University
•
Hard
Arnab Biswas
Used 3+ times
FREE Resource
12 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
SELECT SalespersonID, SUM(SalesAmount) AS TotalSales
FROM Sales
WHERE MONTH(SalesDate) = 1 AND YEAR(SalesDate) = 2023
GROUP BY SalespersonID
ORDER BY TotalSales DESC
LIMIT 5;
SELECT TOP 5 SalespersonID, SUM(SalesAmount) AS TotalSales
FROM Sales
WHERE MONTH(SalesDate) = 1 AND YEAR(SalesDate) = 2023
GROUP BY SalespersonID
ORDER BY TotalSales DESC;
SELECT SalespersonID, SUM(SalesAmount) AS TotalSales
FROM Sales
WHERE SalesDate >= '2023-01-01' AND SalesDate < '2023-02-01'
GROUP BY SalespersonID
ORDER BY TotalSales DESC
LIMIT 5;
SELECT SalespersonID, SUM(SalesAmount) AS TotalSales
FROM Sales
WHERE SalesDate BETWEEN '2023-01-01' AND '2023-01-31'
GROUP BY SalespersonID
ORDER BY TotalSales DESC
FETCH FIRST 5 ROWS ONLY;
2.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Write a SQL query to retrieve the average salary for employees in each department, including only those departments where the average salary is greater than $50,000
SELECT Department, AVG(Salary) AS AvgSalary
FROM Employees
GROUP BY Department
HAVING AVG(Salary) > 50000;
SELECT Department, AVG(Salary) AS AvgSalary
FROM Employees
WHERE AVG(Salary) > 50000
GROUP BY Department;
SELECT Department, AVG(Salary) AS AvgSalary
FROM Employees
HAVING AVG(Salary)> 50000
GROUP BY Department
ORDER BY AvgSalary DESC;
SELECT Department, AVG(Salary) AS AvgSalary
FROM Employees
WHERE Department IN (SELECT Department FROM Employees GROUP BY Department HAVING AvgSalary > 50000)
GROUP BY Department;
3.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Write a SQL query to retrieve the names of all customers who have placed orders for more than 5 distinct products, along with the number of distinct products they have ordered.
SELECT customer_name, COUNT(DISTINCT product_id) AS num_distinct_products
FROM orders
HAVING COUNT(DISTINCT product_id) > 5;
SELECT customer_name, COUNT(DISTINCT product_id) AS num_distinct_products
FROM orders
WHERE COUNT(DISTINCT product_id) > 5
GROUP BY customer_id;
SELECT customer_name, COUNT(DISTINCT product_id) AS num_distinct_products
FROM orders
GROUP BY customer_id
HAVING COUNT(DISTINCT product_id) > 5;
SELECT customer_name, COUNT(DISTINCT product_id) AS num_distinct_products
FROM orders
WHERE customer_id IN (
SELECT customer_id
FROM orders
GROUP BY customer_id
HAVING COUNT(product_id) > 5
)
GROUP BY customer_name;
4.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Write a SQL query to retrieve the names of all products that have been ordered more than 10 times, along with the total number of units ordered and the average order quantity.
SELECT product_name, COUNT(quantity) AS total_units_ordered, AVG(quantity) AS avg_order_quantity
FROM order_items
GROUP BY product_id
HAVING COUNT(quantity) > 10;
SELECT product_name, SUM(quantity) AS total_units_ordered, AVG(quantity) AS avg_order_quantity
FROM order_items
GROUP BY product_id
HAVING SUM(quantity) > 10;
SELECT product_name, SUM(quantity) AS total_units_ordered, AVG(quantity) AS avg_order_quantity
FROM (
SELECT *
FROM order_items
WHERE product_id IN (
SELECT product_id
FROM order_items
GROUP BY product_id
HAVING COUNT(*) > 10
)
) AS subquery
GROUP BY product_id;
SELECT product_name, SUM(quantity) AS total_units_ordered, AVG(quantity) AS avg_order_quantity
FROM order_items
GROUP BY product_type
HAVING SUM(quantity) > 10;
5.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Write a SQL query to retrieve the names of all customers who have placed orders with a total amount greater than the average total amount of all orders, along with the total amount of their orders.
SELECT customer_name, SUM(order_total) AS order_total
FROM orders
GROUP BY customer_id
HAVING order_total > (
SELECT AVG(order_total)
FROM orders
);
SELECT customer_name, SUM(order_total) AS total_order_amount
FROM orders
GROUP BY customer_id
HAVING SUM(order_total) > (
SELECT AVG(order_total)
FROM orders
);
SELECT customer_name, SUM(order_total) AS total_order_amount
FROM orders
WHERE SUM(order_total) > (
SELECT AVG(order_total)
FROM orders
)
GROUP BY customer_id;
SELECT customer_name, SUM(order_total) AS total_order_amount
FROM orders
GROUP BY customer_id
HAVING SUM(order_total) > (
SELECT total_order_amount / COUNT(*)
FROM orders
);
6.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Which of the following SELECT query returns the department number with maximum salary compensated to an employee? (Consider the table structure as given)
SELECT department_id , max(salary ) FROM employees ;
SELECT department_id , max(salary ) FROM employees GROUP BY department_id ;
SELECT max(salary ) FROM employees GROUP BY department_id ;
SELECT max(salary ) FROM employees ;
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
If you don’t specify ASC or DESC after a SQL ORDER BY clause, the following is used by default
ASC
DESC
There is no default value
None of the mentioned
Create a free account and access millions of resources
Similar Resources on Quizizz
10 questions
BEFORE UPS2 - D2T6

Quiz
•
University
15 questions
DBMS_Quiz_1

Quiz
•
University
10 questions
RDBMS

Quiz
•
University
10 questions
Marea recapitulare

Quiz
•
University
15 questions
Parcial N° 2 - DBA

Quiz
•
University
14 questions
FIT 9132 Week 8

Quiz
•
University
10 questions
Quiz Topik Pengantar SQL

Quiz
•
University
10 questions
Quiz-O-Tech Round 2

Quiz
•
University
Popular Resources on Quizizz
39 questions
Respect and How to Show It

Quiz
•
6th Grade
20 questions
math review

Quiz
•
4th Grade
20 questions
Math Review - Grade 6

Quiz
•
6th Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
20 questions
Taxes

Quiz
•
9th - 12th Grade
10 questions
Human Body Systems and Functions

Interactive video
•
6th - 8th Grade
20 questions
Multiplication Facts

Quiz
•
3rd Grade
Discover more resources for Computers
20 questions
Summer

Quiz
•
KG - University
19 questions
Minecraft

Quiz
•
6th Grade - Professio...
20 questions
3rd Grade Review

Quiz
•
KG - University
15 questions
Minecraft

Quiz
•
University
52 questions
Logos Trivia

Quiz
•
KG - University
7 questions
New national park celebrates Harriet Tubman's legacy

Interactive video
•
11th Grade - University
8 questions
2 Step Word Problems

Quiz
•
KG - University
20 questions
Disney characters

Quiz
•
KG - Professional Dev...