Back to Yugabyte Db

GROUPING SETS

community/learn/content/01-SQL-Basics/02-fundamentals/16-grouping-sets.md

2026.1.0.0-b29416 B
Original Source

SELECT with a GROUP BY and GROUPING SETS

In this exercise we will query the suppliers table and group the number_of_people results into city, country and contact_title sets.

SELECT contact_title,
       count(contact_title) AS number_of_people,
       city,
       country
FROM suppliers
GROUP BY GROUPING
SETS (city,
      country,
      contact_title);

This query should return 60 rows