SQL SERVER 2005 提供了行转列方法pivot(),以及列转行unpivot()方法;
但hive 里面没有自带pivot函数,以下为自己实现:
实现将原始表
转为目标表
11
select name ,sum(if(course='math', score, null)) as math ,sum(if(course='english', score, null)) as english ,sum(if(course='chinese', score, null)) as chinese from table_name group by name



