Aggregate Functions

Q: Which of the following is not a built-in aggregate function in SQL?
A: total
Q: What is the result of the following query?
SELECT MAX(Price) FROM Products WHERE Category = 'Electronics';
A: Returns the highest price of all electronics products in the Products table
Q: Which of the following SQL queries returns the average value of a column and rounds the result to two decimal places?
A: SELECT ROUND(AVG(column_name), 2) FROM table_name;
Q: Which of the following SQL queries returns the number of rows in a table?
A: SELECT COUNT() FROM table_name;
Q: Which of the following should be used to find all the courses taught in the Fall 2009 semester but not in the Spring 2010 semester?
A: SELECT DISTINCT course id FROM SECTIONWHERE semester = ’Fall’ AND YEAR= 2009 AND course id NOT IN (SELECT course id FROM SECTION WHERE semester = ’Spring’ AND YEAR= 2010);
Q: Which of the following aggregate functions calculates the average value of a column in SQL?
A: AVG
Q: We apply the aggregate function to a group of sets of tuples using the _______ clause.
A: group by
Q: Observe the given SQL query and choose the correct option.
SELECT branch_name, COUNT (DISTINCT customer_name) 
FROM depositor, account 
WHERE depositor.account_number = account.account_number 
GROUP BY branch_id
A: The query is syntactically wrong
Q: Choose the correct option regarding the query.
SELECT branch_name, COUNT (DISTINCT customer_name) 
FROM depositor, account 
WHERE depositor.account_number = account.account_number 
       GROUP BY branch_id
       HAVING avg(balance) = 10000;
A: The having clause allows only those tuples that have average balance 10000
Q: Which of the following SQL queries returns the number of distinct values in a column?
A: SELECT COUNT(DISTINCT column_name) FROM table_name;