Hive sql 查询数据库查询 top-n
数据库查询*分组排序取top n 要求:按照课程分组,查找每个课程最高的两个成绩。 数据文件如下: 第一列no为学号,第二列course为课程,第三列score为分数 mysql> select * from lesson; +-------+---------+-------+ | no | course | score | +-------+---------+-------+ | N0101 | Marth | 100 | | N0102 | English | 12 | | N0102 | Chinese | 55 | | N0102 | History | 58 | | N0102 | Marth | 25 | | N0103 | English | 100 | | N0103 | Chinese | 87 | | N0103 | History | 88 | | N0103 | Marth | 72 | | N0104 | English | 20 | | N0104 | Chinese | 60 | | N0104 | History | 88 | | N0104 | Marth | 56 | | N0105 | English | 56 | | N0105 | Chinese | 88 | | N0105 | History | 88 | | N0201 |