样例准备
编号 姓名 性别 班级编号
1 name_1 male 1
2 name_2 female 2
3 name_3 male 3
4 name_4 female 4
5 name_5 male 1
6 name_6 female 2
7 name_7 male 3
8 name_8 female 4
9 name_9 male 1
10 name_10 female 2
11 name_11 male 3
12 name_12 female 4
13 name_13 male 1
14 name_14 female 2
15 name_15 male 3
16 name_16 female 4
17 name_17 male 1
18 name_18 female 2
19 name_19 male 3
20 name_20 female 4
21 name_21 male 1
22 name_22 female 2
23 name_23 male 3
班级编号 名称
1 服装
2 机械
3 计算机
5 航天
条件过滤
sql:select * from student where sex='male';
mr:该操作属于比较简单的操作,直接在map阶段对数据进行过滤操作即可。
分组统计
sql:select class_name,count(*) from student group by class_name;
mr: