Skip to main content
added 40 characters in body
Source Link
Oleh Berehovskyi
  • 7.8k
  • 7
  • 30
  • 54

I want to do a query like this:

SELECT Id, Name, Email FROM User WHERE Id IN (SELECT OwnerId FROM Opportunity WHERE AccountId = '001610000085XsNAAU' ORDER BY LastActivityDate DESC NULLS LAST Limit 1)
SELECT Id, Name, Email 
FROM User 
WHERE Id IN (
    SELECT OwnerId 
    FROM Opportunity
    WHERE AccountId = '001610000085XsNAAU'
    ORDER BY LastActivityDate DESC NULLS LAST
    LIMIT 1
)

But I have an error:

expecting a right parentheses, found 'ORDER'

Isn't it possible to use ORDERORDER and LIMITLIMIT in subqueries?

I want to do a query like this:

SELECT Id, Name, Email FROM User WHERE Id IN (SELECT OwnerId FROM Opportunity WHERE AccountId = '001610000085XsNAAU' ORDER BY LastActivityDate DESC NULLS LAST Limit 1)

But I have an error:

expecting a right parentheses, found 'ORDER'

Isn't it possible to use ORDER and LIMIT in subqueries?

I want to do a query like this:

SELECT Id, Name, Email 
FROM User 
WHERE Id IN (
    SELECT OwnerId 
    FROM Opportunity
    WHERE AccountId = '001610000085XsNAAU'
    ORDER BY LastActivityDate DESC NULLS LAST
    LIMIT 1
)

But I have an error:

expecting a right parentheses, found 'ORDER'

Isn't it possible to use ORDER and LIMIT in subqueries?

Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Source Link
grass
  • 119
  • 1
  • 1
  • 9

Limit in WHERE-Clause subquery

I want to do a query like this:

SELECT Id, Name, Email FROM User WHERE Id IN (SELECT OwnerId FROM Opportunity WHERE AccountId = '001610000085XsNAAU' ORDER BY LastActivityDate DESC NULLS LAST Limit 1)

But I have an error:

expecting a right parentheses, found 'ORDER'

Isn't it possible to use ORDER and LIMIT in subqueries?