By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Records: 6 Duplicates: 0 Warnings: 0
Records: 3 Duplicates: 0 Warnings: 0
| id | name |
|---|---|
| 1 | joe |
| 2 | sally |
| 3 | bob |
| id | user_id |
|---|---|
| 1 | 1 |
| 2 | 2 |
| 3 | 1 |
| 4 | 1 |
| 5 | 1 |
| 6 | 2 |
| id | name | task_count |
|---|---|---|
| 1 | joe | 4 |
| 2 | sally | 2 |
| 3 | bob | null |
| id | name | task_count |
|---|---|---|
| 1 | joe | 4 |
| 2 | sally | 2 |
| 3 | bob | 1 |
| id | name | id | user_id |
|---|---|---|---|
| 1 | joe | 5 | 1 |
| 1 | joe | 4 | 1 |
| 1 | joe | 3 | 1 |
| 1 | joe | 1 | 1 |
| 2 | sally | 6 | 2 |
| 2 | sally | 2 | 2 |
| 3 | bob | null | null |
| id | name | sum(if(ut.id is null,0,1)) |
|---|---|---|
| 1 | joe | 4 |
| 2 | sally | 2 |
| 3 | bob | 0 |