Complete the code to define a CTE named 'first_cte' that selects all columns from the 'employees' table.
WITH first_cte AS (SELECT * FROM [1]) SELECT * FROM first_cte;The CTE 'first_cte' must select from the 'employees' table, so the correct answer is 'employees'.
Complete the code to define a second CTE named 'second_cte' that selects only the 'id' and 'name' columns from 'first_cte'.
WITH first_cte AS (SELECT * FROM employees), second_cte AS (SELECT [1] FROM first_cte) SELECT * FROM second_cte;The second CTE selects 'id' and 'name' columns from 'first_cte'.
Fix the error in the code by choosing the correct keyword to reference the first CTE inside the second CTE.
WITH first_cte AS (SELECT * FROM employees), second_cte AS (SELECT id, name FROM [1]) SELECT * FROM second_cte;The second CTE must reference the first CTE by its name 'first_cte'.
Fill both blanks to complete the query that defines two CTEs where the second CTE filters employees with salary greater than 50000.
WITH first_cte AS (SELECT * FROM [1]), second_cte AS (SELECT id, name FROM first_cte WHERE [2] > 50000) SELECT * FROM second_cte;
The first CTE selects from 'employees'. The second CTE filters where 'salary' is greater than 50000.
Fill all three blanks to complete the query that defines three CTEs: first selects employees, second filters by department 'Sales', third selects names and salaries above 60000.
WITH first_cte AS (SELECT * FROM [1]), second_cte AS (SELECT * FROM first_cte WHERE [2] = 'Sales'), third_cte AS (SELECT [3] FROM second_cte WHERE salary > 60000) SELECT * FROM third_cte;
The first CTE selects from 'employees'. The second filters where 'department' equals 'Sales'. The third selects 'name' and 'salary' columns.