如何计算用户在 SQL 内在平台上活跃的天数?

How to count how many days since the user was active on the platform in SQL?

我想知道这个人第一次旅行已经过去了多少天。

我正在尝试这个:

DATEDIFF(day, first_completed_trip_timestamp, CURRENT_DATE) AS days_since_ft

我得到这个错误:

QueryValidation: user_error: Attempt 1: presto: query failed (200 OK): "USER_ERROR: com.facebook.presto.sql.analyzer.SemanticException: line 11:16: Column 'day' cannot be resolved"

您可以 return 只需减去以下值即可将其作为间隔:

(CURRENT_DATE - first_completed_trip_timestamp) as days_since_ft

如果您特别想要天数,请在间隔上使用 day()

day(CURRENT_DATE - first_completed_trip_timestamp) as days_since_ft