By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
| brand | segment | name | total |
|---|---|---|---|
| Toyota | null | null | 15 |
| Toyota | SUV | null | 6 |
| Toyota | SUV | Highlander | 3 |
| Toyota | Sedan | null | 5 |
| Toyota | Sedan | Corolla | 3 |
| x | null | null | 3 |
| x | y | null | 2 |
| x | y | z | 2 |
| x | y2 | null | 1 |
| x | y2 | z2 | 1 |
SELECT 10
| brand | segment | name | total |
|---|---|---|---|
| Toyota | null | null | 15 |
| Toyota | SUV | null | 6 |
| Toyota | SUV | Highlander | 3 |
| Toyota | Sedan | null | 5 |
| Toyota | Sedan | Corolla | 3 |
| x | null | null | 3 |
| x | y | null | 2 |
| x | y | z | 2 |
| x | y2 | null | 1 |
| x | y2 | z2 | 1 |
SELECT 10