Hive与MySQL的不同之GROUP BY

Hive与MySQL的不同之GROUP BY

Hive:

DESC city_info
0 city_id string
1 parent_id string
2 name string
3 type string

SELECT * FROM city_info a GROUP BY city_id;
(tok_table_or_col city_id)
0 100000
1 110000
2 110100

SELECT city_id,parent_id FROM city_info a GROUP BY city_id;
会报错。

MySQL:

SELECT * FROM tb_user a GROUP BY user_name;
会出来所有列

SELECT user_name FROM tb_user a GROUP BY user_name;
会出来1列:user_name

SELECT id FROM tb_user a GROUP BY user_name;
会出来1列:id

SELECT email FROM tb_user a GROUP BY user_name;
会出来1列:email

SELECT id,email FROM tb_user a GROUP BY user_name;
会出来2列:id和email

SELECT id,user_name FROM tb_user a GROUP BY user_name;
会出来2列:id和user_name

    原文作者:元七少
    原文地址: https://www.jianshu.com/p/f606dba32f6a
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞