How Can We Help?
If you like me had multiple Serial that are equal, an really just want to get a single line as output, this can be used.
The important part is ROW_NUMBER() line, deciding which line to use.
WITH q AS (SELECT [Serial] ,[IMEI] ,[Machine Type] ,[Model] ,[comments] ,[Type] ,[Code] ,[Start] ,[End] ,[Name] ,[Description] ,[Contract] ,[Status] ,[SLA] ,ROW_NUMBER() OVER (PARTITION BY Serial ORDER BY [End] DESC) AS rn FROM [WarrantyLenovo]) SELECT Serial, Name, q.[End] INTO #lenovo FROM q WHERE q.rn = 1