赞
踩
姓名 | 语文 | 数学 | 英语 | 物理 | 化学 |
---|---|---|---|---|---|
李小双 | 89 | 78 | 94 | 96 | 87 |
李丽霞 | 94 | 80 | 86 | 78 | 80 |
吴雨涵 | 90 | 67 | 85 | 82 | 60 |
张晓燕 | 87 | 76 | 90 | 79 | 59 |
陈燕文 | 97 | 95 | 92 | 88 | 86 |
在HDFS上创建/hivescore/input目录
将score.txt文件上传到HDFS的/hivescore/input目录
执行命令:hdfs dfs -put score.txt /hivescore/input
SELECT name, SUM(chinese + math + english + physics + chemistry) AS total_score, (SUM(chinese + math + english + physics + chemistry)) / 5 AS average_score FROM t_score GROUP BY name
;改变输出格式
输出格式:
(吴雨涵,384,76.8)
(张晓红,391,78.2)
(李小双,444,88.8)
(王丽霞,418,83.6)
(陈燕文,458,91.6)
执行命令:SELECT CONCAT('(',name,',',total_score,',',average_score,')') AS result FROM (SELECT name,SUM(chinese + math + english + physics + chemistry) AS total_score, (SUM(chinese + math + english + physics + chemistry)) / 5 AS average_score FROM t_score GROUP BY name ) AS subquery;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。