背景
最近有用Clickhouse SQL语句按时间范围查询相关数据,发现时间查询范围不生效,
1.元素SQL
SELECT itemtime, itemid, itemvalue
FROM xxTable where itemid =50040 and
itemtime >='2023-07-31 19:10:00' and itemtime <='2023-07-31 19:12:00'
查询结果如图:
(1)第一种解决方案:
不调整连接工具时区,直接类型转换,SQL语句如下:
SELECT itemtime, itemid, itemvalue,toString(itemtime) as customDate
FROM realdata where itemid =50040 and
customDate >='2023-07-31 19:10:00' and customDate <='2023-07-31 19:12:00'
效果图如下:
(1)第二种解决方案:
修改连接工具时区或者检查服务器本身时间是否正确
重新连接后,再查看SQL语句时间范围筛选是否生效:
end:以上问题仅为日常记录,如有帮助请动手点赞!!!