Q1
True / FalseThe COUNT function can be used to count the number of rows in a table that satisfy a condition.
The COUNT function counts the number of rows that match a specific condition in a query. For example, `SELECT COUNT(*) FROM Orders WHERE Status = 'Shipped';` counts all orders with the status 'Shipped'.
Q2
True / FalseThe SUM function can be used to calculate the total amount of all values in a column.
The SUM function adds up all the values in a specified column. For example, `SELECT SUM(Price) FROM Products;` calculates the total price of all products.
Q3
True / FalseThe AVG function can be used to find the highest value in a column.
The AVG function calculates the average value of a column, not the highest value. The MAX function is used to find the highest value.
Q4
True / FalseThe MIN function returns the smallest value in a column.
The MIN function returns the minimum value from a set of values in a specified column. For example, `SELECT MIN(Salary) FROM Employees;` returns the lowest salary.
Q5
True / FalseThe MAX function can be used to find the minimum price from the Products table.
The MAX function is used to find the highest value, not the minimum. To find the minimum price, you should use the MIN function.
Q6
True / FalseThe COUNT function can be used to count the number of distinct values in a column.
The COUNT function can count distinct values if used with `COUNT(DISTINCT column)`. For example, `SELECT COUNT(DISTINCT Country) FROM Customers;` counts the unique countries in the Customers table.
Q7
True / FalseThe SUM function can be used to calculate the total number of items sold for each product.
The SUM function calculates the total sum of a specified column. To find the total number of items sold for each product, you would use `SUM(Quantity)` and group by the product.
Q8
True / FalseThe AVG function can be used to calculate the total average value of a numeric column.
The AVG function calculates the average value of a numeric column. For example, `SELECT AVG(Salary) FROM Employees;` calculates the average salary of employees.
Q9
True / FalseThe MIN function can be used to find the maximum value in a column.
The MIN function returns the smallest value in a column. To find the maximum value, you should use the MAX function.
Q10
True / FalseThe MAX function can be used to determine the total number of rows in a table.
The MAX function determines the maximum value from a set of values, not the total number of rows. To get the total number of rows, use the COUNT function.
Q11
True / FalseThe COUNT function can be used to count rows where a specific column value is null.
The COUNT function does not count NULL values. To count rows where a column value is NULL, use `COUNT(*)` and filter by `WHERE column IS NULL`.
Q12
True / FalseThe SUM function can be used with the HAVING clause to filter groups by total revenue.
The SUM function can be used with the HAVING clause to filter groups based on their total revenue. For example, `SELECT Department, SUM(Revenue) FROM Sales GROUP BY Department HAVING SUM(Revenue) > 10000;` filters departments with total revenue greater than 10000.
Q13
True / FalseThe AVG function can be used to find the total number of employees in each department.
The AVG function calculates the average value, not the total number of employees. To find the total number of employees in each department, use the COUNT function and group by department.
Q14
True / FalseThe MIN function can be used to find the smallest sale amount for each salesperson.
The MIN function returns the smallest value in a column. To find the smallest sale amount for each salesperson, you can use `SELECT SalespersonID, MIN(SaleAmount) FROM Sales GROUP BY SalespersonID;`.
Q15
True / FalseThe MAX function can be used to find the average salary of employees.
The MAX function returns the maximum value, not the average. To find the average salary of employees, use the AVG function.
Q33
Multiple ChoiceWhich 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;
These queries use the MIN and MAX functions to find the smallest and largest order amounts for each customer.
Q36
Multiple ChoiceWhich 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;
These queries use SUM and AVG functions to calculate the total and average order amounts for each product.
Q38
Multiple ChoiceTo 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;
The MIN function is used to calculate the smallest discount given in each department, grouped by DepartmentID or DepartmentName.
Q42
Multiple ChoiceTo 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;
The AVG function calculates the average order amount for each product, grouped by ProductID or ProductName.
Q43
Multiple ChoiceWhich 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;
These queries use the MAX and MIN functions to find the highest and lowest values for order amounts, sales, discounts, and total amounts.