数仓实习遇到的问题

sql

用法

with用法

https://blog.csdn.net/qq_36617521/article/details/55256382

https://blog.csdn.net/weixin_41600552/article/details/82958942

convert()

https://www.runoob.com/sql/func-convert.html

cube和rollup,grouping

https://www.cnblogs.com/zzhangyuhang/p/9986506.html

https://blog.csdn.net/qq_41805514/article/details/81777946

例子

--t4,t5多出一列作为总计client
t4 as --下一周活跃
(
    select t.weeknum_of_year
           ,decode(grouping(t.platform),1,'client',t.platform) platform --grouping,该函数在其参数列的值为超级分组记录所产生的null时返回1,其他情况返回0.
		                                                                --client 相当于android和ios的总计,group by 产生了null,对应的sum相当于所有platform的总计
           ,count(distinct case when t.is_active >= 1 and t2.is_active >= 1 then t.qimei end ) as cnt_active_w1
      from 
      (
          select *
            from t3 
      ) t 
      join 
      (
          select *
            from t3 
      ) t2 on t.platform = t2.platform and t.qimei = t2.qimei 
      where t2.weeknum_of_year = t.weeknum_of_year+1
      group by t2.weeknum_of_year
               ,cube(t.platform)  --group by() ,group by(t.platform),r如果是cube(a,b),select a,b;那么,在进行group a的时候,因为b为null,这是对比进行聚合函数的操作,可以得到关于a值的相关信息,进行group b的时候,a为null,同理。
			                      --而进行group a,b的时候,就得到了a,b组合起来的详细信息。
								  --group by() ,group by(t.platform)
)
,
t5 as --这一周活跃
(
    select weeknum_of_year
           ,decode(grouping(platform),1,'client',platform) platform
           ,count(distinct case when is_active >= 1 then qimei end ) as cnt_active
      from t3
    group by weeknum_of_year
            ,cube(platform)
)

t4的结果

 

Lateral view

https://blog.csdn.net/clerk0324/article/details/58600284

decode()

https://blog.csdn.net/hyfstyle/article/details/89851895

crontab()

https://www.cnblogs.com/xiao-lei/p/11084578.html

不等于null

is not null

查看数据表一条数据

select * from t limit 1\G;

left join,join

https://blog.csdn.net/minixuezhen/article/details/79763263

full outer join

https://www.cnblogs.com/reaptomorrow-flydream/p/8145610.html 

regexp_replace

https://www.cnblogs.com/woshimrf/p/hive-string-regexp-replace-usage.html

报错

Expression not in GROUP BY key

https://blog.csdn.net/u010003835/article/details/88189948

hive执行报错:Both left and right aliases encountered in JOIN 's1'

https://blog.csdn.net/wisdom_c_1010/article/details/78760454

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值