GROUP BY splits the result into one row per value of the dimensions and
time dimensions you list. Each row has its own metrics, computed from that
row's data alone. Grouped dimensions come first in the result, before the
metrics.
GROUP BY <dimension or time dimension>, …
Only combinations that have data become rows. A month with no sales has no
row. For an unbroken series with zeros, use
TIMESERIES.
Group by dimensions
Each schema page lists its dimensions.
Tickets by activity and ticket type
FROM activities
SHOW tickets_sold, activity_revenue
DURING last_month
GROUP BY activity, activity_variantLead time and length of stay by channel
FROM bookings
SHOW bookings, avg_lead_time_days, avg_length_of_stay
DURING last_year
GROUP BY channelGroup by time
Time dimensions split the time axis into periods.
| Time dimension | One row per | Comes back as |
|---|---|---|
day | day | the date |
week | ISO week, Monday to Sunday | the date of its Monday |
month | month | the first day of the month |
quarter | quarter | the first day of the quarter |
year | year | 1 January |
day_of_week | weekday, across weeks | 1 (Monday) to 7 (Sunday) |
week_of_year | ISO week number, across years | 1 to 53 |
month_of_year | month, across years | 1 (January) to 12 |
Revenue by month and category
FROM revenue
SHOW net_revenue, vat_amount
DURING last_quarter
GROUP BY month, revenue_categoryWhich weekdays fill up
day_of_week puts every Monday in the range in one row, every Tuesday in the
next, and so on.
FROM rooms
SHOW occupancy, adr
DURING last_quarter
GROUP BY day_of_weekThe same week across years
FROM rooms
SHOW room_nights_sold, adr
WHERE week_of_year = 42
SINCE 2023-01-01
GROUP BY yearMetrics that can't split every way
A metric can only split or filter by dimensions that make sense for it. Occupancy has no channel, because an empty room wasn't sold through one:
FROM rooms
SHOW occupancy
DURING last_month
GROUP BY channelEach schema page says which dimensions such metrics split and filter by. Time dimensions work with every metric.