雪花视图-组语法编译错误

时间:2020-05-13 17:59:31

标签: sql snowflake-cloud-data-platform snowsql

我刚刚开始探索Snowflake,并试图创建我的第一个视图。

我在分组时遇到以下语法错误。谁能指导我这里我想念什么?

create or replace view MyView_V1 as 
    select     sum(NUMBER_OF_RECORDS) as total_records, 
               date_part(month, "DATE") as extracted_month, 
               date_part(week, "DATE") as  extracted_week, 
    from        "MV_DB"."MV_SCHEMA"."MV_TABLE",
    group by     extracted_month, extracted_week, 
    order by     extracted_month asc,extracted_week asc;

错误: SQL编译错误:位置0处的语法错误第6行意外出现“ from”。位置0上的语法错误第7行出现意外的“组”。语法错误第8行位于位置0意外的“订单”。

谢谢, 阿克沙特

1 个答案:

答案 0 :(得分:1)

请在from子句前删除逗号并执行查询。

    create or replace view MyView_V1 as 
        select     sum(NUMBER_OF_RECORDS) as total_records, 
                   date_part(month, "DATE") as extracted_month, 
                   date_part(week, "DATE") as  extracted_week
        from        "MV_DB"."MV_SCHEMA"."MV_TABLE"
        group by     extracted_month, extracted_week
        order by     extracted_month asc,extracted_week asc;