> ## Content Index
> Fetch the complete content index at: https://www.bramadams.dev/llms.txt
> Use this file to discover other available public pages before exploring further.

# Complex SQL Query Breakdown Step By Step
- URL: https://www.bramadams.dev/202301091740/
- Published: 2023-01-28T02:30:19.000Z
- Updated: 2023-01-28T02:30:19.000Z
- Author: Bram Adams
- Tags: sql, youtube-notes

```timestamp-url
 <https://www.youtube.com/watch?v=f1vuGPuug9s&ab_channel=DatabaseStar>

```

```timestamp
03:02

```

use the `FROM` clause to understand tables in the query

```timestamp
 04:60

```

`LEFT JOIN` (only join items into the union from the left table) uses a subquery where we can `SELECT` inside and the `JOIN` it on a field to the computed table

```timestamp
 08:50

```

any filters? `HAVING` is filtering where sum values != 0

```timestamp
 14:34

```

Run the main query in parts

## Post Mortem

![https://bram-adams.ghost.io/content/images/2023/01/Complex-SQL-Query-Breakdown-Step-By-Step-Screenshot-2023-01-09-17-42-25.png](https://storage.ghost.io/c/0c/cc/0ccc9a8d-054a-4056-b11e-e1bfbbb66387/content/images/2023/01/Complex-SQL-Query-Breakdown-Step-By-Step-Screenshot-2023-01-09-17-42-25.png)

Complex SQL Query Breakdown Step By Step Screenshot 2023-01-09 17-42-25.png

![https://bram-adams.ghost.io/content/images/2023/01/Complex-SQL-Query-Breakdown-Step-By-Step-Screenshot-2023-01-09-17-46-07.png](https://storage.ghost.io/c/0c/cc/0ccc9a8d-054a-4056-b11e-e1bfbbb66387/content/images/2023/01/Complex-SQL-Query-Breakdown-Step-By-Step-Screenshot-2023-01-09-17-46-07.png)

Complex SQL Query Breakdown Step By Step Screenshot 2023-01-09 17-46-07.png

![https://bram-adams.ghost.io/content/images/2023/01/LEFT-JOIN-Screenshot-2023-01-09-17-48-36.png](https://storage.ghost.io/c/0c/cc/0ccc9a8d-054a-4056-b11e-e1bfbbb66387/content/images/2023/01/LEFT-JOIN-Screenshot-2023-01-09-17-48-36.png)

LEFT JOIN Screenshot 2023-01-09 17-48-36.png