0
0
SQLquery~5 mins

Why subqueries are needed in SQL - Quick Recap

Choose your learning style9 modes available
Recall & Review
beginner
What is a subquery in SQL?
A subquery is a query nested inside another query. It helps to get intermediate results that the main query can use.
Click to reveal answer
beginner
Why do we use subqueries instead of writing one big query?
Subqueries break complex problems into smaller parts, making queries easier to write and understand.
Click to reveal answer
intermediate
How do subqueries help in filtering data?
Subqueries can find specific values first, then the main query uses those values to filter results precisely.
Click to reveal answer
intermediate
Can subqueries be used in SELECT, WHERE, and FROM clauses?
Yes, subqueries can appear in SELECT to calculate values, in WHERE to filter rows, and in FROM to act like temporary tables.
Click to reveal answer
beginner
Give a real-life example where subqueries are useful.
Imagine finding employees who earn more than the average salary. A subquery calculates the average salary, then the main query finds employees above it.
Click to reveal answer
What is the main reason to use a subquery in SQL?
ATo break complex queries into smaller parts
BTo speed up the database server hardware
CTo avoid using any conditions in queries
DTo store data permanently
Where can a subquery NOT be used?
AIn the database schema definition
BIn the FROM clause
CIn the WHERE clause
DIn the SELECT clause
Which of these is a benefit of using subqueries?
AThey make queries harder to read
BThey replace indexes
CThey delete data automatically
DThey allow filtering based on calculated values
A subquery that returns multiple rows can be used with which operator?
ALIKE
BIN
CBETWEEN
DIS NULL
What does a subquery inside the FROM clause act like?
AA database user
BA permanent index
CA temporary table
DA stored procedure
Explain why subqueries are useful when writing SQL queries.
Think about how subqueries help manage complexity and filtering.
You got /4 concepts.
    Describe a scenario where using a subquery is better than a single flat query.
    Consider filtering based on a calculated value like average salary.
    You got /4 concepts.