cannot be applied to timestamp,varchar

select count (distinct if(a.t_time>a.s_time and a.t_time <
date_add(to_date(a.s_time),7),a.id,null))as a_user

这行代码是同事帮忙写的,在presto上并不能查询
'>'cannot be applied to timestamp,varchar
显然,时间戳是不能比较大小的

做出如下修改:

select 
count(distinct if(cast(a.t_time as varchar(40)) >
cast(a.s_time as varchar(40))
and
cast(a.t_time as varchar(40))<
cast(date_add('day',7,cast (substr(a.s_time,1,10)as date))
as varchar(40)),a.number,null))as a_user

cast (time as varchar(40))即可

你可能感兴趣的:(presto,SQL,hive)