Skip to main content
SQL Output Prediction Hard +35 XP

CTE Result

What does this CTE query return?

SQLRead-only
WITH top_earners AS (
  SELECT * FROM employees WHERE salary > 80000
)
SELECT COUNT(*) FROM top_earners;

What is the output?

Show answer and explanation

Answer: Count of employees earning over 80k

A CTE (WITH clause) defines a named temporary result set. The outer query then operates on it like a table.

Hint: CTE creates a temporary named result.

What this challenge tests

Output Prediction in SQL: cte, with-clause.

Related challenges