I have this issue where I want to show only the latest record (Col 1). I deleted the date column thinking that it might not work if it has different values. but if that's the case, then the record itself has a different name (Col 1) because it has a different date in the name of it. Is it possible to fetch one record in this case?
The code:
SELECT distinct p.ID, 
  max(at.Date) as date, 
  at.[RAPID3 Name] as COL1, 
  at.[DLQI Name] AS COL2, 
  at.[HAQ-DI Name] AS COL3,  
  phy.name as phyi, 
  at.State_ID
FROM dbo.[Assessment Tool] as at
Inner join dbo.patient as p on p.[ID] = at.[Owner (Patient)_Patient_ID]
Inner join dbo.[Physician] as phy on phy.ID = p.Physician_ID
where (at.State_ID in (162, 165,168) and p.ID = 5580) 
group by 
at.[RAPID3 Name], 
at.[DLQI Name], 
at.[HAQ-DI Name], 
p.ID, phy.name, 
at.State_ID 
SS:
In this SS I want to show only the latest record (COL 1) of this ID "5580". Means the first row for this ID.
Thank you

 
     
     
     
    