> SELECT land, stadt, abteilung, count(*) FROM personal GROUP BY GROUPING SETS((land, stadt, abteilung), (land, stadt), (land), (), (abteilung), (land, abteilung)) ORDER BY 1, 2, 3; +------+-----------+-----------+-------+ | land | stadt | abteilung | count | +------+-----------+-----------+-------+ | AT | Innsbruck | Personal | 1 | | AT | Innsbruck | | 1 | | AT | | Personal | 1 | | AT | | | 1 | | CH | Zürich | Vertrieb | 1 | | CH | Zürich | | 1 | | CH | | Vertrieb | 1 | | CH | | | 1 | | DE | Berlin | Marketing | 1 | | DE | Berlin | Vertrieb | 1 | | DE | Berlin | | 2 | | DE | Frankfurt | Vertrieb | 1 | | DE | Frankfurt | | 1 | | DE | | Marketing | 1 | | DE | | Vertrieb | 2 | | DE | | | 3 | | | | Marketing | 1 | | | | Personal | 1 | | | | Vertrieb | 3 | | | | | 5 |