add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
select version();
version()
8.0.27
SET @CURRENT_TIME = TIMESTAMP('2022-03-21 13:56:00');

CREATE TABLE t1(
`response_time` INTEGER DEFAULT 0,
`category` INTEGER DEFAULT 0
);

CREATE TABLE anotherTable(
`category` INTEGER DEFAULT 0,
`created_at` DATETIME DEFAULT NULL
);
INSERT INTO t1(response_time, category) VALUES
(15, 1),
(17, 1),
(18, 1);
INSERT INTO anotherTable(category, created_at) VALUES
(1, '2022-03-21 13:40:00'),
(1, '2022-03-21 13:50:00'),
(1, '2022-03-21 13:52:00');
SELECT response_time FROM t1;
response_time
15
17
18
SELECT
anotherTable.created_at,
@CURRENT_TIME,
TIMESTAMPDIFF(MINUTE, anotherTable.created_at, @CURRENT_TIME)
FROM anotherTable;
created_at @CURRENT_TIME TIMESTAMPDIFF(MINUTE, anotherTable.created_at, @CURRENT_TIME)
2022-03-21 13:40:00 2022-03-21 13:56:00 16
2022-03-21 13:50:00 2022-03-21 13:56:00 6
2022-03-21 13:52:00 2022-03-21 13:56:00 4
SELECT response_time, '<=' AS '', TIMESTAMPDIFF(MINUTE, anotherTable.created_at, @CURRENT_TIME), anotherTable.created_at, @CURRENT_TIME
FROM t1
INNER JOIN anotherTable
ON anotherTable.category = t1.category
WHERE t1.response_time <= TIMESTAMPDIFF(MINUTE, anotherTable.created_at, @CURRENT_TIME);
response_time TIMESTAMPDIFF(MINUTE, anotherTable.created_at, @CURRENT_TIME) created_at @CURRENT_TIME
15 <= 16 2022-03-21 13:40:00 2022-03-21 13:56:00