标签:
之前有一位朋友咨询我,Impala中如何实现将多列转为一行,其实Impala中自带函数可以实现,不用自定义函数。
下面我开始演示:
-bash-4.1$ impala-shell
Starting Impala Shell without Kerberos authentication(Shell build version: Impala Shell v1.4.2-cdh5 (eac952d) built on Tue Sep 16 19:15:40 PDT 2014)
[cdha:21000] > create table student(name string,subject string,score decimal(4,1)); -------------创建演示表:student(脱离学校四年了,还不忘自己是学生^_^)------------下面演示有价值的示例,显示高手之招,呵呵
------------这样就可以在一行上面,看到小明和花花的各科成绩了
[cdha:21000] > select name,group_concat(concat_ws(‘=‘,subject,cast(score as string)),‘,‘) from student group by name;
Hive的行列转换请查看: http://blog.csdn.net/jiangshouzhuang/article/details/46810529
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/jiangshouzhuang/article/details/46809931