简体   繁体   English

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

[英]How to get latest 3 months records in presto sql

I would like to find the frequency of logins of user A within the last 3 months but somehow my date filter in the WHERE clause has some errors.. not sure whether the below is a correct way to retrieve latest 3 months records for presto sql.我想找到用户 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 

Wouldn't this work?这行不通?

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

or:或者:

where date_login > cast(current_date - interval '90' day as timestamp)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM