Sub-Queries in T-SQL

Sub-Queries in T-SQL: Types of Sub-Queries, Where to Use Sub-Queries.

Updated

  1. Types of Sub-Queries (Journeyman): A sub-query is a query inside another query, in parentheses. An uncorrelated one runs once on its own; a correlated one uses the outer query's row and runs once per row.
  2. Where to Use Sub-Queries (Journeyman): A sub-query can stand in for a value, a list or a table. Use it in WHERE with =, IN, NOT IN or EXISTS, as a column in the SELECT, or as a table in the FROM.