参考文章:如何在Hive中使用Map类型_hive中map类型
最近遇到的一个问题,例如:有一张表A,表头是stu_id,class_id,class_score
字段说明:stu_id,class_id都是唯一不重复的,class_score字段的内容是maping类型,如{"语文":"80","数学":"90","英语":"95"},现需取出第1个班语文成绩前10名学生及各自的语文成绩
解决:
select
stu_id,
class_score['语文'] as chinese_score
from A
where class_id=1
order by chinese_score desc
limit 10