According to the documentation here

In a syntax statement, the question mark indicates the element preceding it is optional. You may omit the element or include one.

I've never seen a SOQL statement using the ? and in my tests with the Query Editor in the Developers Console only results in errors.

Can anybody tell me how to use the ? in a SOQL, and what it might be good for?

  • These are typographical conventions to read the document.
    – Ashwani
    Oct 1, 2014 at 18:35

2 Answers 2


You wouldn't use "?" in a query. They're saying it marks an optional query element. Here's an example from the documentation:

[ORDER BY fieldExpression ASC | DESC ? NULLS FIRST | LAST ?]

So if you include an "Order By" in your query, the "ASC | DESC" and "FIRST | LAST" elements are optional.

(You appear to be quoting from the SOQL Typographical Conventions which relate to documentation syntax rather than SOQL syntax.)


These are typographical conventions to read the document. So, you could understand it better and implement in example.


SELECT fieldname FROM objectname

In an example or syntax statement, italics represent variables. You supply the actual value.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .