
sql
大大盒子
这个作者很懒,什么都没留下…
展开
-
hive中explode报错UDTF‘s are not supported outside the SELECT clause, nor nested in expressions
hive中使用explode 查询多列时候报错hue中报错信息:Error while compiling statement: FAILED: SemanticException [Error 10081]: UDTF's are not supported outside the SELECT clause, nor nested in expressions原因:UDTF只能查询一个一段也可报错SemanticException 1:40 Only a single expression原创 2020-12-22 18:19:22 · 5957 阅读 · 0 评论 -
main ERROR Unable to invoke factory method in class class org.apache.hadoop.hive.ql.log.HushableRand
报错信息main ERROR Unable to invoke factory method in class class org.apache.hadoop.hive.ql.log.HushableRandomAccessFileAppender for element HushableMutableRandomAccess. java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invo原创 2020-12-14 09:45:42 · 4846 阅读 · 1 评论 -
将‘MM/dd/yyyy‘格式的日期转化成‘yyyy-MM-dd‘形式
实现语句select from_unixtime(unix_timestamp('02/22/2015' ,'MM/dd/yyyy'), 'yyyy-MM-dd')查询结果'2015-02-22'原创 2020-07-07 19:32:23 · 1587 阅读 · 0 评论 -
sql实现上抬一列或者下压一列
目的sql为逐行运算和分组运算,有时候需要本行数据和下一行(上一行)数据进行计算,如间隔多少天登录.元数据需要的算子lead() over()lead(start_dt , 1 , null) over(partition by guid order by start_dt)算子解释...原创 2020-01-30 16:56:42 · 424 阅读 · 0 评论 -
hive中查看某一函数的具体使用方法描述
问题描述当不知道函数的具体名称或者函数的具体使用方法的时候需要进行查询.查询函数的具体名称show functions;查询函数的具体使用方法和作用desc function 加上函数名称;...原创 2020-01-30 16:49:32 · 694 阅读 · 0 评论 -
SQL拼接字符串
目标有时候某些字段需要查询出来的数字前后拼接汉字,如"第n天" 其中n需要时查询出来的具体数字需要算子concat concat_wsselect concat('是','吗');结果select concat_ws('-','是','吗');结果实现代码select concat_ws('n','第','天');select concat_ws(cast(2 as...原创 2020-01-18 21:39:03 · 394 阅读 · 0 评论 -
sql 取出一行中最大值对应的字段名
原始数据目标结果实现思路先把最大品类的字段添加到最后,作为值出现(sql中不能直接拿到字段名)在查询最大值对应的字段名添加最大值对应的字段名到值中selectshop,month,dz,fz,sp,case when dz>fz and dz>sp then 'dz' when fz>dz and fz>sp then 'fz' ...原创 2020-01-17 22:30:18 · 4766 阅读 · 3 评论 -
sql求各季度总和,已知每月数据
原始数据目标数据实现思路1.由于元数据中没有季度标记,需对数据处理,添加上正确的季度,2.按shop和季度进行分组 再进行聚合实现代码添加季度字段selectshop,month,dz,fz,sp,case when month between '2019-01' and '2019-03' then '1季度' when month between '20...原创 2020-01-17 22:05:20 · 3536 阅读 · 1 评论 -
sql中取一行最大值或者最小值
原始数据和目标数据实现SQL语句(最大)selectshop,month,greatest(dz,fz,sp) as maxfromtablename;实现SQL语句(最小)selectshop,month,least (dz,fz,sp) as minfromtablename;...原创 2020-01-17 21:39:13 · 6419 阅读 · 3 评论