| 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:
type Account {
groupBy: Account_GroupBy
orderBy: Account_OrderBy
}
The RecordGroupBy type is introduced by the RecordQueryAggregate type.
RecordGroupBy Type
RecordGroupBy creates one input type per sObject type. For example, Account has a corresponding Account_GroupBy type that you can use with the groupBy argument.
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.
input Account_GroupBy {
AccountNumber: GroupByClause
BillingCity: GroupByClause
BillingCountry: GroupByClause
CreatedBy: User_GroupBy
CreatedById: GroupByClause
Id: GroupByClause
Industry: GroupByClause
Name: GroupByClause
NumberOfEmployees: GroupByClause
OperatingHours: OperatingHours_GroupBy
Owner: User_GroupBy
OwnerId: GroupByClause
Ownership: GroupByClause
Parent: Account_GroupBy
ParentId: GroupByClause
# More fields here
type: GroupByType
}
GroupByType Type
The GroupByType type defines the type of Group By clause.
type GroupByType {
GROUP_BY: GROUP_BY
ROLLUP: ROLLUP
CUBE: CUBE
}
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
The GroupByClause type has a group field of type Boolean. Pass these fields to the groupBy argument in the aggregate field.
type GroupByClause {
group: Boolean
}
The GroupByClause type contains the following field.
group- Pass intrueto thegroupByargument to group the query by the specific field. If true, the field is included in theGroup BySOQL clause.
User_GroupBy Type
Some fields like CreatedBy and OperatingHours correspond to a _GroupBy type, which contains additional fields of type OrderByClause or _GroupBy.
type User_GroupBy {
AboutMe: OrderByClause
Account: Account_OrderBy
AccountId: OrderByClause
# Other User_GroupBy fields
}
GroupByFunction Enum
Use the 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.
note: You can't use group:true for fields of type DateTime and Time. Instead, use these fields with the aggregate functions. See Grouping Examples.
Enum GroupByFunction {
CALENDAR_MONTH
CALENDAR_QUARTER
CALENDAR_YEAR
DAY_IN_WEEK
DAY_IN_MONTH
DAY_IN_YEAR
DAY_ONLY
FISCAL_MONTH
FISCAL_QUARTER
FISCAL_YEAR
HOUR_IN_DAY
WEEK_IN_MONTH
WEEK_IN_YEAR
}
The 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 fromCALENDAR_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 fromCALENDAR_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 fromCALENDAR_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.