GUIDE深度 · Deep dive

Subqueries, EXISTS and Window Functions

A subquery can return one value, one column or many rows: = for single values, IN for multiple rows, EXISTS for existence. Window functions rank/accumulate without collapsing rows.

更新 2026-10-30 · 公式可核验

Subqueries

IN (SELECT ...) for multiple rows.

EXISTS (SELECT 1 ...) for existence.

Correlated subqueries reference the outer table.

Window

ROW_NUMBER() OVER (PARTITION BY ... ORDER BY ...).

Window functions do not reduce rows.

FAQ

Can a subquery return multiple columns?

Yes, but compare with row values/EXISTS.

What is a CTE?

A named temporary result set declared with WITH.

Sources

Related calculators

Advanced SQL: 1000 Gamified JOIN and Subquery Cards1000 advanced SQL cards covering JOIN, GROUP BY/HAVING, subqueries, EXISTS, CASE and window functions, in 50 levels with spaced repetition.

More guides

Hiragana vs KatakanaRead guideSpaced Repetition and the Forgetting CurveRead guideOn Readings vs Kun ReadingsRead guideAn N5 Kanji Study OrderRead guide