SQL Functions and Queries Quiz

Last Updated :
Discuss
Comments

Question 1

Which operator would you use to filter records where a column value is within a range?

  • IN

  • BETWEEN

  • LIKE

  • EXISTS

Question 2

What is the output of SELECT COUNT(DISTINCT department) FROM employees; if 5 departments exist but 3 have NULL values?

  • 5

  • 2

  • 3

  • 8

Question 3

Which GROUP BY clause would correctly summarize sales data by both region and product category?

  • GROUP BY region, category

  • GROUP BY ALL

  • GROUP BY *

  • GROUP BY region AND category

Question 4

A correlated subquery differs from a regular subquery because it:

  • Returns only one row

  • References columns from the outer query

  • Must use EXISTS operator

  • Cannot be used with UPDATE statements

Question 5

Which aggregate function would you use to identify the earliest hire date in a table?

  • SUM()

  • MIN()

  • MAX()

  • AVG()

Question 6

Which aggregate function counts only non-NULL values in a specific column?

  • COUNT(*)

  • COUNT(column_name)

  • SUM(column_name)

  • AVG(column_name)

Question 7

Which operator checks if a subquery returns any rows?

  • IN

  • ANY

  • EXISTS

  • UNIQUE

Question 8

What is the result of SELECT SUM(salary)/COUNT(*) FROM employees; if one employee has a NULL salary?

  • Average salary excluding NULL values

  • Average salary excluding NULL

  • Results in a division-by-zero error

  • Returns NULL for the calculation

Question 9

Which aggregate function returns the highest value in a column?

  • MIN()

  • COUNT()

  • AVG()

  • MAX()

Question 10

What does GROUP BY ROLLUP(region, department) do?

  • Groups by region only

  • Creates hierarchical subtotals (region → department → grand total)

  • Randomizes group order

  • Filters NULL groups

There are 10 questions to complete.

Take a part in the ongoing discussion