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_UNIXTIME(`date`)
,CONVERT_TZ(FROM_UNIXTIME(`date`),'SYSTEM','+00:00')
FROM
`data`
WHERE
`date` >= '1654635600'
AND `date` <= '1654721999'
/*
GROUP BY
`time`,
`partner`
ORDER BY
`time`
*/
partner | time | FROM_UNIXTIME(`date`) | CONVERT_TZ(FROM_UNIXTIME(`date`),'SYSTEM','+00:00') |
---|---|---|---|
0 | 23 | 2022-06-08 00:52:28 | 2022-06-07 23:52:28 |
0 | 23 | 2022-06-08 00:55:01 | 2022-06-07 23:55:01 |
0 | 4 | 2022-06-08 05:00:35 | 2022-06-08 04:00:35 |
0 | 5 | 2022-06-08 06:29:25 | 2022-06-08 05:29:25 |
0 | 5 | 2022-06-08 06:29:25 | 2022-06-08 05:29:25 |
0 | 9 | 2022-06-08 10:49:46 | 2022-06-08 09:49:46 |
0 | 13 | 2022-06-08 14:00:15 | 2022-06-08 13:00:15 |
0 | 13 | 2022-06-08 14:02:13 | 2022-06-08 13:02:13 |