Hi elvisidrizi1,
You need to first find out difference between hours one you will get the difference in Hours after that you need to check conditions.
Please refer below Sql Query.
SQL
CREATE TABLE #Lake
(
Id INT IDENTITY(1,1),
V INT,
Akey VARCHAR(10),
EventProcessedUtcTime DATETIME,
EventEnqueuedUtcTime DATETIME
)
INSERT INTO #Lake VALUES(75, 'somekey', '2022-04-11T13:50:02Z', '2022-04-11T12:49:56Z');
INSERT INTO #Lake VALUES(76, 'somekey', '2022-04-11T14:50:02Z', '2022-04-11T12:49:56Z');
INSERT INTO #Lake VALUES(77, 'somekey', '2022-04-11T15:50:02Z', '2022-04-11T12:49:56Z');
INSERT INTO #Lake VALUES(78, 'somekey', '2022-04-11T16:50:02Z', '2022-04-11T12:49:56Z');
INSERT INTO #Lake VALUES(79, 'somekey', '2022-04-11T17:50:02Z', '2022-04-11T12:49:56Z');
INSERT INTO #Lake VALUES(80, 'somekey', '2022-04-11T18:50:02Z', '2022-04-11T12:49:56Z');
INSERT INTO #Lake VALUES(81, 'somekey', '2022-04-11T19:50:02Z', '2022-04-11T12:49:56Z');
INSERT INTO #Lake VALUES(76, 'somekey', '2022-04-11T20:50:02Z', '2022-04-11T12:49:56Z');
INSERT INTO #Lake VALUES(77, 'somekey', '2022-04-11T21:50:02Z', '2022-04-11T12:49:56Z');
INSERT INTO #Lake VALUES(78, 'somekey', '2022-04-11T22:50:02Z', '2022-04-11T12:49:56Z');
INSERT INTO #Lake VALUES(79, 'somekey', '2022-04-11T23:50:02Z', '2022-04-11T12:49:56Z');
SELECT * FROM #Lake AS HoursDiffrence WHERE DATEDIFF(HOUR, EventEnqueuedUtcTime, EventProcessedUtcTime) <= 24
DROP TABLE #Lake
Output