7

1) Working:

SELECT CreatedDate, Account.CreatedDate FROM Opportunity
WHERE CALENDAR_YEAR(CreatedDate) = 2016

2) Working:

SELECT CreatedDate, Account.CreatedDate FROM Opportunity
WHERE CALENDAR_YEAR(Account.CreatedDate) = 2016

Above two SOQL are working in developer console. But SOQL below is not working. I want to know why SOQL WHERE clause behave like this OR there are any syntax error in my SOQL

3) Unknown error parsing query

SELECT CreatedDate, Account.CreatedDate FROM Opportunity
WHERE CALENDAR_YEAR(CreatedDate) = CALENDAR_YEAR(Account.CreatedDate)

4) Unknown error parsing query

SELECT CreatedDate, Account.CreatedDate FROM Opportunity
WHERE CALENDAR_YEAR(CreatedDate) = : CALENDAR_YEAR(Account.CreatedDate)
  • I suspect it is because the CreatedDate in the first query is not explicitly from either Account or Opportunity. – Dave Humm Feb 8 '16 at 10:11
10

Each element of the where clause is limited to being only a fieldExpression:

fieldName comparisonOperator value

where the value cannot be a reference to another field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.