+ Start a Discussion
moverdorfmoverdorf 

Order By Help... Should be an easy one

I have the following query, but I need to order the results by ActivityDate in descending order.

 

SELECT (SELECT
         ActivityDate,
         Description,
         Subject,
         IsClosed,
         CallType,
         CallDisposition,
         Status,
         ActivityType
        FROM OpenActivities
        )
FROM Account

 

if I put order by ActivityDate desc like so:

 

SELECT (SELECT
         ActivityDate,
         Description,
         Subject,
         IsClosed,
         CallType,
         CallDisposition,
         Status,
         ActivityType
        FROM OpenActivities

        order by AcivityDate desc
        )
FROM Account

 

It comes out the same order as if I don't have any order by. Can anyone tell me how to get the order in the way I need it?

 

Thanks so much.

 

 

Vinita_SFDCVinita_SFDC

Hello,

 

I believe your API version is 13 or above. Try querying like this:

 

SELECT (SELECT
         ActivityDate,
         Description,
         Subject,
         IsClosed,
         CallType,
         CallDisposition,
         Status,
         ActivityType
        FROM OpenActivities

        ORDER BY AcivityDate DESC NULLS LAST
        )
FROM Account