
SQL
春风化雨~_~
守得云开见月明
展开
-
hivesql中使用join 关联表时where 和 on、join 的执行先后顺序
环境:hive 0.13.1版本select t1.cust_pty_no,t2.amtfrom a t1left join b t2on t1.cust_pty_no = t2.cust_pty_no and t2.busi_date='2020-04-17'where t1.busi_date='2020-04-17'使用expalin 查看执行计划如下:看红色圈住部分,n...原创 2020-05-05 16:07:16 · 16693 阅读 · 15 评论 -
开窗函数 row_number()
找出一个表中重复出现的记录例如 b表中是客户的购物信息,找出购物两次或者两次以上的客户select * from ( select name ,row_number() over(partition by name )rn --开窗函数,组内排序 from shop ) a where a.rn>1 --出现次数大于1的客户;执行结果:...原创 2019-10-23 11:22:19 · 583 阅读 · 0 评论 -
MySQL中的Group By是否允许SELECT非聚合列的总结
在SQL92以及更早的SQL标准中不允许查询除了GROUP BY之外的非聚合的列,例如如下查询即非法:select o.custid,c.name max(o.payment) from order as o ,customers as cwhere o.custid=c.custidgroup by o.custid因为c.name没有在group中,因此解决方案是删除c.nam...原创 2019-10-23 09:24:57 · 728 阅读 · 0 评论 -
SQL中NULL 值!= NULL
sql 中的null 值是不等于null的,当你在使用sql左连接查询的时候(类似连接),即使途中这两条记录的name,year,month 是一致的(包含null)但在sql 筛选出来的结果是认为不一致的tips: sql 中:null !=null --> true‘222’ != null --> true因此在做逻辑运算的时候,如果有可能出现空值,需要将空值替换成...原创 2019-10-23 09:17:11 · 9246 阅读 · 1 评论 -
SQL
hive sql --with as踩过的坑with as 与insert into 共用的时候要注意顺序问题原创 2019-09-29 14:52:52 · 278 阅读 · 0 评论