List only the latest records from a date column


Microsoft SQL server 2016


How list only the latest rows with the same date in the update column?


Create a view – who will only list the latest row based on the date column;

CREATE VIEW [DM].[AccountView-Latest]
SELECT [key_dimAccount]
FROM [DM].[dimAccount]
WHERE UpdateDate = ( SELECT MAX(UpdateDate) FROM [DM].[dimAccount ] )

The where statement will only take the latest date (max) from the updatedate column – should give a list with only the records that are updated at same date.


More Information: