Grokking SQL for Tech Interviews
Ask Author
Back to course home

0% completed

Vote For New Content

Types of Subqueries
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Subqueries can be categorized based on where they appear in an SQL statement and their purpose. They are categorized as,

  1. Nested Scalar Subquery
  2. Single-Row Subquery
  3. Multiple-Row Subquery
  4. Single-Column Subquery
  5. Correlated Subquery

Example Data

The given table will be used for the demonstration of subtypes of nested queries.

1. Nested Scalar Subquery

A Nested Scalar Subquery returns a single value and is often used in a comparison. In this example, we retrieve the student_name where the student_id is the maximum.

Query

SELECT student_name FROM students

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible