0
0
SQLquery~10 mins

WITH clause syntax in SQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start a WITH clause in SQL.

SQL
WITH [1] AS (SELECT * FROM employees)
Drag options to blanks, or click blank then click option'
Atemp_table
BSELECT
CFROM
DWHERE
Attempts:
3 left
💡 Hint
Common Mistakes
Using SQL keywords like SELECT or FROM as the name.
Leaving the name blank.
2fill in blank
medium

Complete the code to select all columns from the WITH clause named temp_table.

SQL
WITH temp_table AS (SELECT id, name FROM employees) SELECT [1] FROM temp_table;
Drag options to blanks, or click blank then click option'
Aid
B*
Cname
Demployees
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting a single column instead of all columns.
Using the original table name instead of the WITH clause name.
3fill in blank
hard

Fix the error in the WITH clause by completing the missing keyword.

SQL
WITH temp_table [1] (SELECT id FROM employees) SELECT * FROM temp_table;
Drag options to blanks, or click blank then click option'
AFROM
BINTO
CWHERE
DAS
Attempts:
3 left
💡 Hint
Common Mistakes
Using FROM instead of AS.
Omitting the keyword entirely.
4fill in blank
hard

Fill both blanks to create two WITH clauses and select from the second.

SQL
WITH [1] AS (SELECT id FROM employees), [2] AS (SELECT id FROM departments) SELECT * FROM [2];
Drag options to blanks, or click blank then click option'
Aemp_ids
Bdept_ids
Cemployees
Ddepartments
Attempts:
3 left
💡 Hint
Common Mistakes
Using original table names instead of new names.
Mixing up the order of names.
5fill in blank
hard

Fill all three blanks to create a WITH clause, filter rows, and select specific columns.

SQL
WITH filtered_emps AS (SELECT [1], [2] FROM employees WHERE salary [3] 50000) SELECT * FROM filtered_emps;
Drag options to blanks, or click blank then click option'
Aid
Bname
C>
Ddepartment
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting columns not in the table.
Using wrong comparison operators like '<' or '='.