Hi,
Create Table dbo.#test
(
date datetime,
Person varchar(25),
Type varchar(25),
time time
)
Insert into dbo.#test (Date, Person, Type, Time)
Values ('20180521','X','Morning','04:15')
Insert into dbo.#test (Date, Person, Type, Time)
Values ('20180521','X','Morning','04:16')
Insert into dbo.#test (Date, Person, Type, Time)
Values ('20180521','Y','Morning','04:17')
Insert into dbo.#test (Date, Person, Type, Time)
Values ('20180521','Y','Morning','04:19')
Insert into dbo.#test (Date, Person, Type, Time)
Values ('20180521','Y','Afternoon','11:25')
Insert into dbo.#test (Date, Person, Type, Time)
Values ('20180521','Y','Afternoon','11:25')
Insert into dbo.#test (Date, Person, Type, Time)
Values ('20180521','Y','Afternoon','11:28')
Insert into dbo.#test (Date, Person, Type, Time)
Values ('20180521','X','Afternoon','11:28')
GO
select Date, Person, Max(Type), time from dbo.#test
Group by date, Person, Time
The above query produces the result like this
Basically, if the time difference is just 1 minute, it should not display it. If more than 1 minute, it should display the row.