SQL Athena获取过去12个月的数据

问题描述

我需要获取过去12个月的数据。我在AWS Athena中使用SQL。下面是我的代码:

CREATE
OR REPLACE VIEW response_view AS
SELECT
    "cust"."customer_id","cust"."event_triggered_date"
FROM
    (
        db.population_view pop
        INNER JOIN new_db.manual_response_view cust ON ("pop"."customer_id" = "cust"."customer_id")
    )
    WHERE "cust"."event_triggered_date" > current_date - interval '12' month

给我一​​个错误:cannot be applied to varchar,date

event_triggered_filed是一个字符串

这是日期字段的结构:2019-12-04 00:00:00.000

解决方法

尝试一下。

CAST(EVENT_TRIGGERED_DATE AS DATE)

OR

CAST(EVENT_TRIGGERED_DATE AS TIMESTAMP )

Data Types

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...