Update Query
use [iQDataHub-EDW]
go

update r
set r.[IsLastApproved] = case when t.[ResolveDeviceInstanceToDeviceID] is not null then 1 else 0 end
from hub.[ResolveDeviceInstanceToDevice] r
left join (
	select ROW_NUMBER() over (
			partition by rss.[DeviceID] order by rss.[DeviceInstanceID] desc
			) as [Row]
		,rss.[ResolveDeviceInstanceToDeviceID]
		,rss.[DeviceID]
		,rss.[DeviceInstanceID]
		,t.[FullDate]
	from [hub].[ResolveDeviceInstanceToDevice] rss with (nolock)
	inner join [hub].[Dataset] ds with (nolock)
		on ds.[DatasetID] = rss.[DatasetID] and ISNULL(ds.[IsApproved], 0) = 1
	inner join [hub].[Time] t with (nolock)
		on t.[TimeID] = ds.[ImportTimeID]
	) t
	on t.[ResolveDeviceInstanceToDeviceID] = r.[ResolveDeviceInstanceToDeviceID] and [Row] = 1;
