By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE `data` (
`id` bigint NOT NULL,
`cid` bigint NOT NULL,
`from` int NOT NULL,
`partner` int NOT NULL,
`date` int NOT NULL
);
ALTER TABLE `data`
ADD PRIMARY KEY (`id`);
ALTER TABLE `data`
MODIFY `id` bigint NOT NULL AUTO_INCREMENT;
INSERT INTO `data` VALUES (null,2222,33,0,1654645948),
(null,2222,33,0,1654646101),
(null,2222,33,0,1654660835),
(null,2222,33,0,1654666165),
(null,2222,33,0,1654666165),
(null,2222,33,0,1654681786),
(null,2222,33,0,1654693215),
(null,2222,33,0,1654693333)
SELECT
`partner`,
COUNT(`cid`) AS `count`,
(`date` MOD 86400) DIV 3600 AS `time`
FROM
`data`
WHERE
`date` >= '1654635600'
AND `date` <= '1654721999'
GROUP BY
`time`,
`partner`
ORDER BY
`time`
partner | count | time |
---|---|---|
0 | 1 | 4 |
0 | 2 | 5 |
0 | 1 | 9 |
0 | 2 | 13 |
0 | 2 | 23 |