Microsoft SQL Server Database Quiz Questions

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

The COUNT function can be used to count the number of rows in a table that satisfy a condition.

Q2
True / False

The SUM function can be used to calculate the total amount of all values in a column.

Q3
True / False

The AVG function can be used to find the highest value in a column.

Q4
True / False

The MIN function returns the smallest value in a column.

Q5
True / False

The MAX function can be used to find the minimum price from the Products table.

Q6
True / False

The COUNT function can be used to count the number of distinct values in a column.

Q7
True / False

The SUM function can be used to calculate the total number of items sold for each product.

Q8
True / False

The AVG function can be used to calculate the total average value of a numeric column.

Q9
True / False

The MIN function can be used to find the maximum value in a column.

Q10
True / False

The MAX function can be used to determine the total number of rows in a table.

Q11
True / False

The COUNT function can be used to count rows where a specific column value is null.

Q12
True / False

The SUM function can be used with the HAVING clause to filter groups by total revenue.

Q13
True / False

The AVG function can be used to find the total number of employees in each department.

Q14
True / False

The MIN function can be used to find the smallest sale amount for each salesperson.

Q15
True / False

The MAX function can be used to find the average salary of employees.

Q16
Single Choice

Which function is used to find the total number of products sold?

SQL Code
SELECT SUM(Quantity) FROM Sales;
Q17
Single Choice

Which function would you use to find the highest salary in a table?

SQL Code
SELECT MAX(Salary) FROM Employees;
Q18
Single Choice

To calculate the average order value, which function should be used?

SQL Code
SELECT AVG(OrderValue) FROM Orders;
Q19
Single Choice

Which function calculates the smallest price in a table?

SQL Code
SELECT MIN(Price) FROM Products;
Q20
Single Choice

Which function calculates the total revenue from sales?

SQL Code
SELECT SUM(Revenue) FROM Sales;
Q21
Single Choice

Which function is used to count the number of unique customers?

SQL Code
SELECT COUNT(DISTINCT CustomerID) FROM Orders;
Q22
Single Choice

To get the total number of employees in each department, which function is used?

SQL Code
SELECT DepartmentID, COUNT(EmployeeID) FROM Employees GROUP BY DepartmentID;
Q23
Single Choice

To determine the highest sale amount for each product, which function should be used?

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

Which function would be used to find the average discount applied to orders?

SQL Code
SELECT AVG(Discount) FROM Orders;
Q25
Single Choice

To calculate the total quantity sold for each category, which function should be used?

SQL Code
SELECT CategoryID, SUM(Quantity) FROM Sales GROUP BY CategoryID;
Q26
Single Choice

To find the smallest order amount from each customer, which function should be used?

SQL Code
SELECT CustomerID, MIN(OrderAmount) FROM Orders GROUP BY CustomerID;
Q27
Single Choice

Which function is used to calculate the average salary of employees in each department?

SQL Code
SELECT DepartmentID, AVG(Salary) FROM Employees GROUP BY DepartmentID;
Q28
Single Choice

To determine the total revenue for each region, which function should be used?

SQL Code
SELECT Region, SUM(Revenue) FROM Sales GROUP BY Region;
Q29
Single Choice

Which function calculates the total number of orders placed?

SQL Code
SELECT COUNT(OrderID) FROM Orders;
Q30
Single Choice

Which function finds the highest price of products?

SQL Code
SELECT MAX(Price) FROM Products;
Q31
Multiple Choice

Which SQL query calculates the total revenue for each product category?

SQL Code
SELECT CategoryID, SUM(Revenue)
FROM Sales
GROUP BY CategoryID;

SELECT CategoryName, SUM(Revenue)
FROM Sales
JOIN Categories ON Sales.CategoryID = Categories.CategoryID
GROUP BY CategoryName;

SELECT CategoryID, SUM(SaleAmount)
FROM Sales
GROUP BY CategoryID;

SELECT CategoryID, SUM(OrderAmount)
FROM Orders
GROUP BY CategoryID;
Q32
Multiple Choice

Which query finds the average salary of employees in each department?

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

SELECT DepartmentName, AVG(Salary)
FROM Employees
JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID
GROUP BY DepartmentName;

SELECT DepartmentID, AVG(Salary)
FROM Employees
GROUP BY DepartmentID
HAVING AVG(Salary) > 50000;

SELECT DepartmentID, AVG(Salary)
FROM Employees
WHERE Salary IS NOT NULL
GROUP BY DepartmentID;
Q33
Multiple Choice

Which queries calculate the smallest and largest order amounts for each customer?

SQL Code
SELECT CustomerID, MIN(OrderAmount), MAX(OrderAmount)
FROM Orders
GROUP BY CustomerID;

SELECT CustomerID, MIN(Amount), MAX(Amount)
FROM Orders
GROUP BY CustomerID;

SELECT CustomerID, MIN(TotalAmount), MAX(TotalAmount)
FROM Invoices
GROUP BY CustomerID;

SELECT CustomerID, MIN(PurchaseAmount), MAX(PurchaseAmount)
FROM Transactions
GROUP BY CustomerID;
Q34
Multiple Choice

Which function is used to calculate the total number of orders with a discount greater than 10?

SQL Code
SELECT COUNT(OrderID)
FROM Orders
WHERE Discount > 10;

SELECT SUM(Quantity)
FROM Orders
WHERE Discount > 10;

SELECT AVG(OrderAmount)
FROM Orders
WHERE Discount > 10;

SELECT MAX(OrderAmount)
FROM Orders
WHERE Discount > 10;
Q35
Multiple Choice

To find the average discount given in each region, which function should be used?

SQL Code
SELECT Region, AVG(Discount)
FROM Orders
GROUP BY Region;

SELECT Region, AVG(Discount)
FROM Sales
GROUP BY Region;

SELECT Region, SUM(Discount)
FROM Orders
GROUP BY Region;

SELECT Region, MIN(Discount)
FROM Orders
GROUP BY Region;
Q36
Multiple Choice

Which queries calculate the total and average order amounts for each product?

SQL Code
SELECT ProductID, SUM(OrderAmount), AVG(OrderAmount)
FROM Orders
GROUP BY ProductID;

SELECT ProductID, COUNT(OrderID), AVG(OrderAmount)
FROM Orders
GROUP BY ProductID;

SELECT ProductID, SUM(OrderAmount)
FROM Orders
GROUP BY ProductID;

SELECT ProductID, AVG(OrderAmount)
FROM Orders
GROUP BY ProductID;
Q37
Multiple Choice

Which function would be used to find the highest value in a list of discounts?

SQL Code
SELECT MAX(Discount)
FROM Orders;

SELECT MIN(Discount)
FROM Orders;

SELECT AVG(Discount)
FROM Orders;

SELECT SUM(Discount)
FROM Orders;
Q38
Multiple Choice

To calculate the smallest discount given in each department, which function should be used?

SQL Code
SELECT DepartmentID, MIN(Discount)
FROM Orders
GROUP BY DepartmentID;

SELECT DepartmentName, MIN(Discount)
FROM Orders
JOIN Departments ON Orders.DepartmentID = Departments.DepartmentID
GROUP BY DepartmentName;

SELECT DepartmentID, MIN(Discount)
FROM Sales
GROUP BY DepartmentID;

SELECT DepartmentID, MAX(Discount)
FROM Orders
GROUP BY DepartmentID;
Q39
Multiple Choice

Which queries use the SUM function to calculate the total sales for each product?

SQL Code
SELECT ProductID, SUM(SalesAmount)
FROM Sales
GROUP BY ProductID;

SELECT ProductName, SUM(SalesAmount)
FROM Sales
JOIN Products ON Sales.ProductID = Products.ProductID
GROUP BY ProductName;

SELECT ProductID, SUM(Quantity)
FROM Orders
GROUP BY ProductID;

SELECT ProductID, COUNT(SalesAmount)
FROM Sales
GROUP BY ProductID;
Q40
Multiple Choice

Which function is used to find the average quantity of products ordered in each region?

SQL Code
SELECT Region, AVG(Quantity)
FROM Orders
GROUP BY Region;

SELECT Region, AVG(OrderAmount)
FROM Orders
GROUP BY Region;

SELECT Region, SUM(Quantity)
FROM Orders
GROUP BY Region;

SELECT Region, COUNT(OrderID)
FROM Orders
GROUP BY Region;
Q41
Multiple Choice

Which function calculates the total number of distinct orders placed by each customer?

SQL Code
SELECT CustomerID, COUNT(DISTINCT OrderID)
FROM Orders
GROUP BY CustomerID;

SELECT CustomerID, COUNT(DISTINCT OrderAmount)
FROM Orders
GROUP BY CustomerID;

SELECT CustomerID, COUNT(OrderID)
FROM Orders
GROUP BY CustomerID;

SELECT CustomerID, COUNT(DISTINCT CustomerName)
FROM Orders
GROUP BY CustomerID;
Q42
Multiple Choice

To find the average order amount for each product, which function is appropriate?

SQL Code
SELECT ProductID, AVG(OrderAmount)
FROM Orders
GROUP BY ProductID;

SELECT ProductName, AVG(OrderAmount)
FROM Orders
JOIN Products ON Orders.ProductID = Products.ProductID
GROUP BY ProductName;

SELECT ProductID, SUM(OrderAmount)
FROM Orders
GROUP BY ProductID;

SELECT ProductID, COUNT(OrderAmount)
FROM Orders
GROUP BY ProductID;
Q43
Multiple Choice

Which queries can be used to find the maximum and minimum order amounts?

SQL Code
SELECT MAX(OrderAmount), MIN(OrderAmount)
FROM Orders;

SELECT MAX(SaleAmount), MIN(SaleAmount)
FROM Sales;

SELECT MAX(Discount), MIN(Discount)
FROM Orders;

SELECT MAX(TotalAmount), MIN(TotalAmount)
FROM Invoices;
Q44
Multiple Choice

Which function calculates the total number of records in a table?

SQL Code
SELECT COUNT(*)
FROM Orders;

SELECT COUNT(OrderID)
FROM Orders;

SELECT COUNT(DISTINCT OrderID)
FROM Orders;

SELECT SUM(Quantity)
FROM Orders;
Q45
Multiple Choice

Which queries use the COUNT function to determine the number of orders placed by each employee?

SQL Code
SELECT EmployeeID, COUNT(OrderID)
FROM Orders
GROUP BY EmployeeID;

SELECT EmployeeName, COUNT(OrderID)
FROM Orders
JOIN Employees ON Orders.EmployeeID = Employees.EmployeeID
GROUP BY EmployeeName;

SELECT EmployeeID, COUNT(DISTINCT OrderID)
FROM Orders
GROUP BY EmployeeID;

SELECT EmployeeID, COUNT(OrderAmount)
FROM Orders
GROUP BY EmployeeID;