PDI · Question #208
Which three data types can a SOQL query return? Choose 3 answers
The correct answer is A. List C. Integer D. sObJect. A SOQL query primarily returns a List of sObject records; however, aggregate queries can also return single scalar values like Integer for counts.
Question
Which three data types can a SOQL query return? Choose 3 answers
Options
- AList
- BLong
- CInteger
- DsObJect
- EDouble
How the community answered
(20 responses)- A90% (18)
- B5% (1)
- E5% (1)
Why each option
A SOQL query primarily returns a List of sObject records; however, aggregate queries can also return single scalar values like Integer for counts.
The most common return type for a SOQL query is a List of sObject records, for example, List<Account> or List<Contact>.
While Long is a valid Apex data type, SOQL aggregate functions like COUNT() return Integer if the count fits, or use COUNT(fieldname) which returns Integer. A direct SOQL query doesn't explicitly return a Long type for standard data.
For aggregate functions like COUNT(), a SOQL query can return an Integer value representing the count of records.
Each row returned by a SOQL query, representing a record, is of the sObject type, or a specific child type like Account or Contact. A query returns a List of these sObject instances.
While Double is a valid Apex data type for decimals, SOQL aggregate functions for sums (SUM()) or averages (AVG()) typically return Decimal type, not Double.
Concept tested: SOQL return types
Source: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL_sosl.htm
Topics
Community Discussion
No community discussion yet for this question.