Presto - static date and timestamp in where clause

前端 未结 2 914
悲&欢浪女
悲&欢浪女 2021-02-03 17:58

I\'m pretty sure the following query used to work for me on Presto:

select segment, sum(count)
from modeling_trends
where segment=\'2557172\' and date = \'2016-0         


        
2条回答
  •  盖世英雄少女心
    2021-02-03 18:31

    Unlike some other databases, Presto doesn't automatically convert between varchar and other types, even for constants. The cast works, but a simpler way is to use the type constructors:

    WHERE segment = '2557172'
      AND date = date '2016-06-23'
      AND count_time BETWEEN timestamp '2016-06-23 14:00:00.000' AND timestamp '2016-06-23 14:59:59.000'
    

    You can see examples for various types here: https://prestosql.io/docs/current/language/types.html

提交回复
热议问题