栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

hive sql 离奇识别不了?

hive sql 离奇识别不了?

select
    t.app_type,
    t.cnt,
    (cast(t.cnt as double)/cast(all.all_count as double)) as percent
from
    (
        select
            app_type,
            count(*) as cnt
        from
            xxx
        where
            dt='2022-02-26'
        group by
            app_type
    ) t
    cross join (
        select
            count(*) as all_count
        from
            xxx
        where
            dt='2022-02-26'
    ) all
order by
    t.cnt desc
limit
    6;

报错:

Error: Error while compiling statement: FAILED: ParseException line 4:60 cannot recognize input near 'as' 'percent' 'from' in selection target (state=42000,code=40000)

然后 把 as percent 去掉后,暂且能跑通了。

疑问:为什么 as percent 设置一个别名,那个SB SQL 就报错了呢?

解答:all、percent 都是关键字(保留字)。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/747960.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号