Introduction
Sometimes you want to use the result of one query as a temporary table inside another query. This helps break down complex questions into smaller parts.
When you want to calculate some values first and then use them to filter or sort results.
When you need to join a summary table with another table.
When you want to organize your query in steps for better understanding.
When you want to reuse a set of rows temporarily without creating a permanent table.