SELECT 
    ,[ID]
    ,[Name]
    ,[Age]
    ,[CheckTime]
FROM Record
What I have now
| ID | Name | Age | CheckTime | 
|---|---|---|---|
| 12 | Alex | 23 | 2022-08-16 06:16:46.000 | 
| 13 | Cynthia | 45 | 2022-08-16 06:16:53.000 | 
| 14 | Kwabeng | 57 | 2022-08-16 07:54:44.000 | 
| 14 | Kwabeng | 57 | 2022-08-16 07:54:51.000 | 
| 15 | Asante | 23 | 2022-08-16 07:54:32.000 | 
| 16 | Leticia | 98 | 2022-08-16 07:58:32.000 | 
| 16 | Leticia | 98 | 2022-08-16 07:45:49.000 | 
| 12 | Mercy | 23 | 2022-08-16 07:42:36.000 | 
From the table id number 14 and 16 have been repeated but just that the Date is different, I want to remove one of the record
What I want
| ID | Name | Age | CheckTime | 
|---|---|---|---|
| 12 | Alex | 23 | 2022-08-16 06:16:46.000 | 
| 13 | Cynthia | 45 | 2022-08-16 06:16:53.000 | 
| 14 | Kwabeng | 57 | 2022-08-16 07:54:44.000 | 
| 15 | Asante | 23 | 2022-08-16 07:54:32.000 | 
| 16 | Leticia | 98 | 2022-08-16 07:58:32.000 | 
| 12 | Mercy | 23 | 2022-08-16 07:42:36.000 | 
I was able to achieve that with FORMAT(CheckTime,'yyyy-MM-dd:HH') but it has converted the CheckTime to string but I want the CheckTime in datetime format to help in filtering records by date
SELECT ID, Name, Age, FORMAT(CheckTime, 'yyyy-MM-dd:HH') AS [DateHour]
    , COUNT(Name) AS [Age]
FROM Record
GROUP BY ID,Name, Age, FORMAT(CheckTime, 'yyyy-MM-dd:HH'),
 
     
     
    
