Chapter-4 Querying and SQL Functions — Online MCQ Test
INFORMATICS PRACTICES · Grade 12 · CBSE(NCERT)
Practice Chapter-4 Querying and SQL Functions with a free chapter-wise online MCQ test.
This chapter covers: SQL - single row functions - aggregate functions - SUM - AVG - COUNT - MAX - MIN - GROUP BY - HAVING - ORDER BY - table joins.
AI-generated questions from basic to board-exam level, with instant results and explanations.
Chapter-4 Querying and SQL Functions — Important Questions & Answers
Which SQL function is used to count the number of rows in a table?
- A. SUM()
- B. COUNT()
- C. AVG()
- D. MAX()
Answer: B. COUNT()
COUNT() is the aggregate function specifically designed to count the number of rows that match a specified condition in a table.
COUNT() is the aggregate function specifically designed to count the number of rows that match a specified condition in a table.
What does the AVG() function return?
- A. The total sum of all values
- B. The average or mean value of a numeric column
- C. The highest value in a column
- D. The lowest value in a column
Answer: B. The average or mean value of a numeric column
AVG() calculates and returns the average (mean) of all numeric values in a specified column.
AVG() calculates and returns the average (mean) of all numeric values in a specified column.
Which of the following is NOT an aggregate function?
- A. SUM()
- B. COUNT()
- C. ROUND()
- D. AVG()
Answer: C. ROUND()
ROUND() is a scalar/single-row function that rounds numeric values, not an aggregate function that operates on multiple rows.
ROUND() is a scalar/single-row function that rounds numeric values, not an aggregate function that operates on multiple rows.
What is a single-row function in SQL?
- A. A function that works on multiple rows at once
- B. A function that processes each row independently and returns one result per input row
- C. A function used only with GROUP BY
- D. A function that can only be used in WHERE clause
Answer: B. A function that processes each row independently and returns one result per input row
Single-row functions operate on each row individually and return one result for each input row, unlike aggregate functions that work on multiple rows.
Single-row functions operate on each row individually and return one result for each input row, unlike aggregate functions that work on multiple rows.
Consider this scenario: You need to find the department with the highest total salary expense. Which query structure is most appropriate?
- A. SELECT Department FROM Employees ORDER BY Salary DESC LIMIT 1
- B. SELECT Department, SUM(Salary) FROM Employees GROUP BY Department ORDER BY SUM(Salary) DESC LIMIT 1
- C. SELECT Department, MAX(Salary) FROM Employees GROUP BY Department
- D. SELECT Department FROM Employees WHERE Salary = MAX(Salary)
Answer: B. SELECT Department, SUM(Salary) FROM Employees GROUP BY Department ORDER BY SUM(Salary) DESC LIMIT 1
This query correctly groups by department, sums all salaries per department, orders by total salary descending, and limits to the top result.
This query correctly groups by department, sums all salaries per department, orders by total salary descending, and limits to the top result.