222wan

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

hive清洗数据sql语句报错

在本次的测试中sql语句清洗数据时下面,同时观察第一个语句中Date为啥要加这个单引号,原因是Date是sql语句里的可以说是一个关键字的存在,所以必须要单独引用起来以示区别

1
insert overwrite table article select ip as ip ,`Date` as `Date`,day as day ,traffic as traffic,type as type,id as id from now1 where now1.type like 'article%' group by id,ip,`Date`,day ,traffic,type;

  插入语句,后面的group by后面要写的数据名,以我的理解啊,就是前面select后面的xx as xx中如果没有被什么函数或者其他的类型包裹着那就必须写在后面,也就是说这里的全部列都要写在后面,但是下面这样的语句只用写ID,和  sale_num

insert overwrite table jieguo01 select day_id as day_id ,sale_num as sale_num,sum(count) as count ,sum(round) as round from sample2 where sample2.sale_num like 'O%' group by day_id, sale_num;

  

posted on   角落的蘑菇  阅读(25)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示