222wan

导航

hive清洗数据sql语句报错

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

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 2023-10-13 22:38  角落的蘑菇  阅读(17)  评论(0编辑  收藏  举报