SQL Query get most recent activiy per account (efficient query)
问题 I use MS SQL Server 2016 and try to query the MS Dynamics 2016 on-premise DB efficiently. You don't need special knowledge about Dynamics to answer my problem because it's rather an SQL but a CRM problem. Suppose you have entities FilteredAccounts and FilteredActivities (that's the name in Dynamics View) FilteredActivites have the following columns: accountid name FilteredActivites have the following columns: activityid actualend [DATETIME] regardingobjectid (referring to account) statecode