GROUP BY
GROUP BY splits the numbers into rows, one for each value of a field.
FROM dealsSHOW count, won_valueGROUP BY owner, stageSyntax
Section titled “Syntax”GROUP BY [ONLY] [TOP <n>] <field> [OVERALL][, <field> ...]| Grouping | Example |
|---|---|
| A field of the object | GROUP BY stage, GROUP BY owner |
| A custom property | GROUP BY customer_tier, GROUP BY "Customer tier" |
| A related object’s field | GROUP BY accounts.industry |
| One specific reference | GROUP BY decision_maker.title |
| A time unit | GROUP BY month, GROUP BY day_of_week |
Time units
Section titled “Time units”day, week, month, quarter, year, day_of_week, hour_of_day, week_of_year, and month_of_year.
GROUP BY month lists only the months that have data. To list every month in the period, with zeros where nothing happened, use TIMESERIES.
Related fields and roles
Section titled “Related fields and roles”accounts.industry follows every link between the record and accounts. To follow one specific reference instead, write the reference’s name and a dot, for example a deal’s decision maker:
FROM dealsSHOW countGROUP BY decision_maker.titleKeep the biggest groups and fold the rest into an Other row:
FROM dealsSHOW won_valueGROUP BY TOP 5 owner| Form | Result |
|---|---|
TOP 5 owner |
The five biggest owners, plus Other |
ONLY TOP 5 owner |
The five biggest owners, no Other row |
TOP 5 owner OVERALL |
With two groupings, ranks owners across everything instead of within each value of the first grouping |
Groups are ranked by the first metric you show.