Group By Schema
|AVAILABLE API VERSION|
|API v58.0 and later|
All sObjects in the schema have a corresponding
RecordGroupBy type. The
RecordGroupBy type combines the object API name with the
_GroupBy suffix. For example:
RecordGroupBy type is introduced by the
RecordGroupBy creates one input type per sObject type. For example, Account has a corresponding
Account_GroupBy type that you can use with the
Account_GroupBy type contains fields of
GroupByClause. Some fields are shown here for brevity. We recommend that you use the Altair GraphQL client for a complete view of the schema.
GroupByType type defines the type of
Group By clause.
GroupByType contains these fields.
GROUP_BY- The default grouping.
ROLLUP- Adds subtotals for aggregated data in the query result.
CUBE- Adds subtotals for all combinations of a grouped field in the query results.
GroupByClause type has a
group field of type
Boolean. Pass these fields to the
groupBy argument in the
GroupByClause type contains the following field.
group- Pass in
groupByargument to group the query by the specific field. If true, the field is included in the
Group BySOQL clause.
Some fields like
OperatingHours correspond to a
_GroupBy type, which contains additional fields of type
GroupByFunction enumeration with fields of type DateTime and Time. Fields of type DateTime and Time cannot be included with their field name alone, and so providing
group: true for those field types is invalid.
You can't use
group:true for fields of type DateTime and Time. Instead, use these fields with the aggregate functions. See Grouping Examples.
GroupByFunction enumeration contains these values.
CALENDAR_MONTH- Returns a number 1 (January) to 12 (December) for the calendar month on a date field.
CALENDAR_QUARTER- Returns a number 1 (January 1 - March 31) to 4 (October 1 through December 31) for the calendar quarter on a date field.
CALENDAR_YEAR- Returns the calendar year on a date field.
DAY_IN_WEEK- Returns a number 1 (Sunday) to 7 (Saturday) for the day of the week on a date field.
DAY_IN_MONTH- Returns a number 1–31 for the day in the month on a date field.
DAY_IN_YEAR- Returns a number 1–365 for the day in the year on a date field.
DAY_ONLY- Returns a date for the day portion on a DateTime field, for example,
2009-09-22for September 22, 2009.
FISCAL_MONTH- Returns a number 1–12 for the discal month on a date field, which can differ from
CALENDAR_MONTHif your organization uses a fiscal year that does not match the Gregorian calendar. This field is not supported if your organization has custom fiscal years enabled.
FISCAL_QUARTER- Returns a number 1–4 for the fiscal quarter on a date field, which can differ from
CALENDAR_QUARTERif your organization uses a fiscal year that does not match the Gregorian calendar. This field is not supported if your organization has custom fiscal years enabled.
FISCAL_YEAR- Returns the fiscal year on a date field, which can differ from
CALENDAR_YEARif your organization uses a fiscal year that does not match the Gregorian calendar.
HOUR_IN_DAY- Returns a number 1–24 for the hour in the day on a DateTime field. Only DateTime and Time fields are supported.
WEEK_IN_MONTH- Returns a number 1–5 for the week in the month on a date field.
WEEK_IN_YEAR- Returns a number 1–53 for the week in the year on a date field.