使用的数据库 clickHouse
程序查询出来时14.4
直接执行Sql查询出来是14.2
select round(sum(current_play_time) / 60 / 60, 1)
from (SELECT max(current_play_time) as current_play_time
FROM probe_records
WHERE toDateTime(log_time, 'Asia/Shanghai') >= '2024-05-11 00:00:00.0'
and toDateTime(log_time, 'Asia/Shanghai') <= '2024-05-11 23:59:59.0'
group by user_id, start_time) as t
实际上程序格式的时间 2024-05-11 23:59:59.0,也就是上面这段sql直接拿去执行是会失败的,但是在myabtis中并没有失败,而且结果是错的
最后手动格式化时间解决了这个问题
select round(sum(current_play_time) / 60 / 60, 1)
from (SELECT max(current_play_time) as current_play_time
FROM probe_records
WHERE toDateTime(log_time, 'Asia/Shanghai') >= '2024-05-11 00:00:00'
and toDateTime(log_time, 'Asia/Shanghai') <= '2024-05-11 23:59:59'
group by user_id, start_time) as t
后续验证sql和程序的结果一致