如何在presto sql中获取最近3个月的记录

如何在presto sql中获取最近3个月的记录,sql,presto,Sql,Presto,我想查找用户A在过去3个月内的登录频率,但我在WHERE子句中的日期过滤器有一些错误。。不确定以下是否是检索presto sql最近3个月记录的正确方法 select userid, count(*) from user_login where userid = 3321 and date(from_unixtime(cast(date_login as int)) >= date_add('day',-90,current_date)) group by 1 这不管用吗 where

我想查找用户A在过去3个月内的登录频率,但我在WHERE子句中的日期过滤器有一些错误。。不确定以下是否是检索presto sql最近3个月记录的正确方法

select userid, count(*)
from user_login
where userid = 3321 and date(from_unixtime(cast(date_login as int)) >= date_add('day',-90,current_date))
group by 1 
这不管用吗

where date_login > cast(date_add(day, -90, current_date) as timestamp)
或:


date\u login
的数据类型是什么?您的日期函数又错过了一个。@adelle。您应该能够将该值转换为时间戳。
where date_login > cast(current_date - interval '90' day as timestamp)