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