Microsoft SQL Server Database Quiz Questions

Chapter Name:Chapter 7 - DQL (Data Query Language)
Lesson Content Link:GROUP BY
Current Quiz Count:45
Progress
0%
Q1
True / False

The GROUP BY clause is used to arrange identical data into groups.

Q2
True / False

You can use the GROUP BY clause without any aggregate functions.

Q3
True / False

The HAVING clause can be used without a GROUP BY clause.

Q4
True / False

The GROUP BY clause can be used with the ORDER BY clause.

Q5
True / False

Columns in the SELECT statement that are not part of aggregate functions must be included in the GROUP BY clause.

Q6
True / False

The GROUP BY clause can group rows based on the values of one or more columns.

Q7
True / False

The GROUP BY clause must be placed before the WHERE clause in a SQL statement.

Q8
True / False

Aggregate functions can be used directly in the WHERE clause without the GROUP BY clause.

Q9
True / False

GROUP BY can be used to arrange data based on derived columns.

Q10
True / False

The HAVING clause can filter data after it has been grouped by the GROUP BY clause.

Q11
True / False

GROUP BY can be used with SELECT INTO statements.

Q12
True / False

GROUP BY and DISTINCT can be used together in a single query.

Q13
True / False

The GROUP BY clause is optional when using aggregate functions.

Q14
True / False

You can use column aliases in the GROUP BY clause.

Q15
True / False

The GROUP BY clause can be used with multiple columns to create nested groups.

Q16
Single Choice

Which SQL query correctly groups the employees by their department?

SQL Code
SELECT DepartmentID, COUNT(*)
FROM Employees
GROUP BY DepartmentID;
Q17
Single Choice

Which SQL query correctly groups the sales data by year?

SQL Code
SELECT YEAR(SaleDate) AS SaleYear, SUM(SaleAmount)
FROM Sales
GROUP BY YEAR(SaleDate);
Q18
Single Choice

How do you group the orders by customer ID?

SQL Code
SELECT CustomerID, COUNT(OrderID)
FROM Orders
GROUP BY CustomerID;
Q19
Single Choice

Which query shows the total quantity of products sold by each supplier?

SQL Code
SELECT SupplierID, SUM(Quantity)
FROM OrderDetails
GROUP BY SupplierID;
Q20
Single Choice

How do you calculate the average order amount for each customer?

SQL Code
SELECT CustomerID, AVG(OrderAmount)
FROM Orders
GROUP BY CustomerID;
Q21
Single Choice

Which SQL query correctly groups the employees by their job title?

SQL Code
SELECT JobTitle, COUNT(*)
FROM Employees
GROUP BY JobTitle;
Q22
Single Choice

Which query shows the highest sales amount for each product?

SQL Code
SELECT ProductID, MAX(SaleAmount)
FROM Sales
GROUP BY ProductID;
Q23
Single Choice

How do you group the sales data by region?

SQL Code
SELECT Region, SUM(SaleAmount)
FROM Sales
GROUP BY Region;
Q24
Single Choice

Which SQL query correctly groups the employees by their manager ID?

SQL Code
SELECT ManagerID, COUNT(EmployeeID)
FROM Employees
GROUP BY ManagerID;
Q25
Single Choice

How do you group the inventory data by product category?

SQL Code
SELECT ProductCategory, SUM(Quantity)
FROM Inventory
GROUP BY ProductCategory;
Q26
Single Choice

Which SQL query correctly groups the orders by their status?

SQL Code
SELECT OrderStatus, COUNT(*)
FROM Orders
GROUP BY OrderStatus;
Q27
Single Choice

How do you group the sales data by product and customer?

SQL Code
SELECT ProductID, CustomerID, SUM(SaleAmount)
FROM Sales
GROUP BY ProductID, CustomerID;
Q28
Single Choice

Which query shows the total sales amount for each sales representative?

SQL Code
SELECT SalesRepID, SUM(SaleAmount)
FROM Sales
GROUP BY SalesRepID;
Q29
Single Choice

How do you group the customer orders by order date?

SQL Code
SELECT OrderDate, COUNT(OrderID)
FROM Orders
GROUP BY OrderDate;
Q30
Single Choice

Which SQL query correctly groups the products by their category?

SQL Code
SELECT ProductCategory, COUNT(*)
FROM Products
GROUP BY ProductCategory;
Q31
Multiple Choice

Which SQL query groups the employees by department and calculates the total salary for each department?

SQL Code
SELECT DepartmentID, SUM(Salary)
FROM Employees
GROUP BY DepartmentID;
Q32
Multiple Choice

Which SQL query groups the products by supplier and calculates the total quantity for each supplier?

SQL Code
SELECT SupplierID, SUM(Quantity)
FROM Products
GROUP BY SupplierID;
Q33
Multiple Choice

Which SQL query groups the sales data by region and calculates the average sales amount for each region?

SQL Code
SELECT Region, AVG(SaleAmount)
FROM Sales
GROUP BY Region;
Q34
Multiple Choice

Which SQL query groups the orders by customer and calculates the highest order amount for each customer?

SQL Code
SELECT CustomerID, MAX(OrderAmount)
FROM Orders
GROUP BY CustomerID;
Q35
Multiple Choice

Which SQL query groups the employees by job title and calculates the total number of employees in each job title?

SQL Code
SELECT JobTitle, COUNT(*)
FROM Employees
GROUP BY JobTitle;
Q36
Multiple Choice

Which SQL query groups the sales data by product category and calculates the total sales amount for each category?

SQL Code
SELECT ProductCategory, SUM(SaleAmount)
FROM Sales
GROUP BY ProductCategory;
Q37
Multiple Choice

Which SQL query groups the orders by order date and calculates the total number of orders for each date?

SQL Code
SELECT OrderDate, COUNT(*)
FROM Orders
GROUP BY OrderDate;
Q38
Multiple Choice

Which SQL query groups the inventory data by product category and calculates the average quantity for each category?

SQL Code
SELECT ProductCategory, AVG(Quantity)
FROM Inventory
GROUP BY ProductCategory;
Q39
Multiple Choice

Which SQL query groups the employees by department and calculates the average salary for each department?

SQL Code
SELECT DepartmentID, AVG(Salary)
FROM Employees
GROUP BY DepartmentID;
Q40
Multiple Choice

Which SQL query groups the sales data by product and calculates the highest sales amount for each product?

SQL Code
SELECT ProductID, MAX(SaleAmount)
FROM Sales
GROUP BY ProductID;
Q41
Multiple Choice

Which SQL query groups the customer orders by customer ID and calculates the total order amount for each customer?

SQL Code
SELECT CustomerID, SUM(OrderAmount)
FROM Orders
GROUP BY CustomerID;
Q42
Multiple Choice

Which SQL query groups the sales data by sales representative and calculates the average sales amount for each representative?

SQL Code
SELECT SalesRepID, AVG(SaleAmount)
FROM Sales
GROUP BY SalesRepID;
Q43
Multiple Choice

Which SQL query groups the employees by job title and calculates the highest salary for each job title?

SQL Code
SELECT JobTitle, MAX(Salary)
FROM Employees
GROUP BY JobTitle;
Q44
Multiple Choice

Which SQL query groups the sales data by region and calculates the highest sales amount for each region?

SQL Code
SELECT Region, MAX(SaleAmount)
FROM Sales
GROUP BY Region;
Q45
Multiple Choice

Which SQL query groups the products by category and calculates the total quantity for each category?

SQL Code
SELECT ProductCategory, SUM(Quantity)
FROM Products
GROUP BY ProductCategory;