
FIT 9132 Week 10
Authored by Arnab Biswas
Computers
University
Used 3+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
12 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Write a SQL query to retrieve the top 5 salespeople with the highest total sales amount for the month of January 2023
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
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
12 questions
Gala night Youth 2021
Quiz
•
University
10 questions
INTRODUCCION A LA PROGRAMACION
Quiz
•
6th Grade - University
10 questions
Quiz 1: Introducción a Windows Server
Quiz
•
University
15 questions
SIMKOM
Quiz
•
12th Grade - Professi...
14 questions
Information Technology Application in Construction Quiz
Quiz
•
University
10 questions
MS Office
Quiz
•
University
13 questions
IT1 E
Quiz
•
University
10 questions
DBMS 1
Quiz
•
University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
29 questions
Alg. 1 Section 5.1 Coordinate Plane
Quiz
•
9th Grade
22 questions
fractions
Quiz
•
3rd Grade
11 questions
FOREST Effective communication
Lesson
•
KG
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
Discover more resources for Computers
12 questions
IREAD Week 4 - Review
Quiz
•
3rd Grade - University
7 questions
Fragments, Run-ons, and Complete Sentences
Interactive video
•
4th Grade - University
7 questions
Renewable and Nonrenewable Resources
Interactive video
•
4th Grade - University
10 questions
DNA Structure and Replication: Crash Course Biology
Interactive video
•
11th Grade - University
5 questions
Inherited and Acquired Traits of Animals
Interactive video
•
4th Grade - University
5 questions
Examining Theme
Interactive video
•
4th Grade - University
20 questions
Implicit vs. Explicit
Quiz
•
6th Grade - University
7 questions
Comparing Fractions
Interactive video
•
1st Grade - University