Grouping results and filtering duplicates by the row's date
Because you have other columns that you're not aggregating (name) but are eliminating rows based on the date column (latest record only), using GROUP BY is not ideal.
You can use windowing functions to find the specific record based on the grouping (code) and return only those records.
Example:
WITH CTE AS
(
  SELECT code
    , name
    , date
    , ROW_NUMBER() OVER (PARTITION BY code ORDER BY date DESC) AS [RowNumber]
  FROM Records
)

SELECT *
FROM CTE
WHERE RowNumber = 1

You can see a working example here. Basically it is using a CTE and the ROW_NUMBER function to assign a row number to each row within the code groups in a date descending order. This means you can simply select each row where the ROW_NUMBER value is 1.