Select sum from latest values in table
The query you showed is not running as-is, where's this CFID alias coming from?

As SQL Server supports Standard SQL's Analytical Functions you might rewrite MAX/Subquery using RANK (or ROW_NUMBER):

SELECT ...
FROM
  ( SELECT CDM.CompanyId, 
           any additonal columns you need,
           RANK() OVER (PARTITION BY CDM.CompanyId
                        ORDER BY CDM.[Date] DESC) AS rnk
        FROM [{schema}].[CompanyData] CDM
            INNER JOIN #Locations T
                ON T.LocationId = CDM.CompanyId
  ) TM
WHERE rnk = 1