目录
一、首先要创建表:在txt记事本中先输入创建语句备用,创建class1~class5的表。
三、创建数据库zhh,用户为zhh,之后将之前写在txt记事本里的创建表class1~class5的命令复制到hive当中:
四、将txt里的数据上传到/data/zhh/class1(class1~class5依次进行)
- create table class5(
- num String comment'this is the xuhao of students',
- xuehao String comment 'this is the xuehao of students',
- name String comment 'this is the name of student',
- banji String comment 'this is the banji of students',
- kqbxcj String comment 'this is the kaoqinbiaoxianchengji of students',
- pszycj String comment 'this is the pingshizuoyechengji of student',
- qimocj String comment 'this is the qimochengji of student',
- zhcj String comment'this is the zonghechengji of students'
- )
- row format delimited fields terminated by ',' stored as textfile
- location '/data/zhh/class5';
相关命令:
start-all.sh
mysql5.7/support-files /mysql.server start
命令:hdfs dfs -put class01.txt /data/zhh/class
1、查询2019级1班ETL技术期末考试的综合分数80分以上的学生信息(含80分)。
命令:select *from class1 where zhcj>=80;
2、查询2019级1班ETL技术期末考试考试成绩90分以上的学生信息(含90分)。
命令:select *from class1 where qimocj>=90;
3、统计2019级1班ETL技术期末考试成绩70分以上的学生人数(含70分)。
命令:select count(*) from class1 where qimocj>=70;
4、统计2019级2班ETL技术期末考试成绩及格的学生人数。
命令:select count(*) from class2 where qimocj>=60;
5、统计2019级1班参加ETL技术考试的学生总人数(序号数即为人数则课使用num为关键字查询)。
命令:select count(num) from class1;
6、统计2019级2班参加ETL技术考试的学生总人数。
命令:select count(num) from class2;
7、统计2019级3班参加ETL技术考试的学生总人数。
命令:select count(*) from class3;
8、统计2019级4班参加ETL技术考试的学生总人数。
命令:select count(*) from class4;
9、统计2019级数据科学与大数据技术全年级的学生总人数。
命令:select count(*) from class5;
10、查询2019级全年级ETL技术的期末考试成绩80分及以上的学生信息。
命令:select * from class5 where qimocj>=80;
11、查询2019级全年级ETL技术的期末综合成绩85分及以上的学生信息。
命令:select * from class5 where qmcj>=85;
12、统计2019级全年级ETL技术的期末综合成绩86分及以上的学生的总人数。
命令:select count(zhcj>=86) from class5 ;
13、查询2019级数据科学与大数据技术1班吉苇同学的学号、以及所有成绩。
命令:select xuehao,name,kqbxcj,qimocj,zhcj from class1 where name=”吉苇”;
14、查询2019级数据科学与大数据技术2班彭艳同学的学号、以及所有成绩。
命令:select xuehao,name,kqbxcj,qimocj,zhcj from class2 where name=”彭艳”;
15、统计2019级1班ETL技术的期末综合成绩不及格的学生人数。
命令:select count(*) from class1 where zhcj>=60;
16、统计2019级全年级ETL技术的期末综合成绩不及格的学生人数。
命令:select count(*) from class5 where zhcj<60;
17、分析出2019级全年级ETL技术的期末考试成绩分布在70-85分之间的学生信息。
命令:select * from class5 where qimocj between 70 and 85;
18、分析出2019级1班ETL技术的期末考试成绩分布在70-79分之间的学生信息。
命令:select * from class1 where qimocj between 70 and 79;
19、分析出2019级2班ETL技术的期末考试成绩分布在60-69分之间的学生信息。
命令:select * from class2 where qimocj between 60 and 69;
20、统计2019级数据科学与大数据技术全年级学生的期末综合成绩80分以上的学生人数(含80分)。
命令:select count(*) from class5 where qimocj>=80;
结束!