diff --git "a/\346\235\250\345\207\214\347\277\224 22/.keep" "b/\346\235\250\345\207\214\347\277\224 22 01/.keep" similarity index 100% rename from "\346\235\250\345\207\214\347\277\224 22/.keep" rename to "\346\235\250\345\207\214\347\277\224 22 01/.keep" diff --git "a/\346\235\250\345\207\214\347\277\224 22/\346\235\250\345\207\214\347\277\224 22/\344\275\234\344\270\232/student.sql" "b/\346\235\250\345\207\214\347\277\224 22 01/\346\235\250\345\207\214\347\277\224 22/\344\275\234\344\270\232/student.sql" similarity index 100% rename from "\346\235\250\345\207\214\347\277\224 22/\346\235\250\345\207\214\347\277\224 22/\344\275\234\344\270\232/student.sql" rename to "\346\235\250\345\207\214\347\277\224 22 01/\346\235\250\345\207\214\347\277\224 22/\344\275\234\344\270\232/student.sql" diff --git "a/\346\235\250\345\207\214\347\277\224 22/\346\235\250\345\207\214\347\277\224 22/\347\254\224\350\256\260/2020-9-16-\345\273\272\345\272\223\345\273\272\350\241\250.md" "b/\346\235\250\345\207\214\347\277\224 22 01/\346\235\250\345\207\214\347\277\224 22/\347\254\224\350\256\260/2020-9-16-\345\273\272\345\272\223\345\273\272\350\241\250.md" similarity index 100% rename from "\346\235\250\345\207\214\347\277\224 22/\346\235\250\345\207\214\347\277\224 22/\347\254\224\350\256\260/2020-9-16-\345\273\272\345\272\223\345\273\272\350\241\250.md" rename to "\346\235\250\345\207\214\347\277\224 22 01/\346\235\250\345\207\214\347\277\224 22/\347\254\224\350\256\260/2020-9-16-\345\273\272\345\272\223\345\273\272\350\241\250.md" diff --git "a/\346\235\250\345\207\214\347\277\224 22 02/.keep" "b/\346\235\250\345\207\214\347\277\224 22 02/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\346\235\250\345\207\214\347\277\224 22 02/\344\275\234\344\270\232/test.sql" "b/\346\235\250\345\207\214\347\277\224 22 02/\344\275\234\344\270\232/test.sql" new file mode 100644 index 0000000000000000000000000000000000000000..03d5e5a27505b6c735a0fae8a738def39adc5205 --- /dev/null +++ "b/\346\235\250\345\207\214\347\277\224 22 02/\344\275\234\344\270\232/test.sql" @@ -0,0 +1,65 @@ +--1. 查询出武汉地区所有的员工信息,要求显示部门名称以及员工的详细资料 + +select * from People +inner join Department on People.DepartmentId=Department.DepartmentId +where PeopleAddress='武汉' + +--2. 查询出武汉地区所有的员工信息,要求显示部门名称,职级名称以及员工的详细资料 + +select * from People +inner join Department on People.DepartmentId=Department.DepartmentId +inner join Rank on People.RankId=Rank.RankId +where PeopleAddress ='武汉' + +--3. 根据部门分组统计员工人数,员工工资总和,平均工资,最高工资和最低工资。 + +select DepartmentName,COUNT(People.DepartmentId)人数,SUM(PeopleSalary)工资总和,AVG(PeopleSalary)平均工资,MAX(PeopleSalary)最高工资,MIN(PeopleSalary)最低工资 from People +inner join Department on People.DepartmentId=Department.DepartmentId +group by DepartmentName + +--4. 根据部门分组统计员工人数,员工工资总和,平均工资,最高工资和最低工资,平均工资在10000 以下的不参与统计,并且根据平均工资降序排列。 + +select DepartmentName,COUNT(People.DepartmentId)人数,SUM(PeopleSalary)工资总和,AVG(PeopleSalary)平均工资,MAX(PeopleSalary)最高工资,MIN(PeopleSalary)最低工资 from People +inner join Department on People.DepartmentId=Department.DepartmentId +group by DepartmentName +having AVG(PeopleSalary)>=10000 +order by AVG(PeopleSalary) desc + +--5. 根据部门名称,然后根据职位名称,分组统计员工人数,员工工资总和,平均工资,最高工资和最低工资 + +select DepartmentName,RankId,COUNT(People.DepartmentId)人数,SUM(PeopleSalary)工资总和,AVG(PeopleSalary)平均工资,MAX(PeopleSalary)最高工资,MIN(PeopleSalary)最低工资 from People +inner join Department on People.DepartmentId=Department.DepartmentId +group by RankId,DepartmentName + +--6.查询出巨蟹 6.22--7.22 的员工信息 + +select * from People where MONTH(PeopleBirth)+CONVERT(float,DAY(PeopleBirth))/100 between 6.22 and 7.22 + +--7.查询所有员工信息,添加一列显示属相(鼠,牛,虎,兔,龙,蛇,马,羊,猴,鸡,狗,猪) + +select *, case + when year(PeopleBirth)%12 =0 + then '猴' + when YEAR(PeopleBirth)%12=1 + then '鸡' + when YEAR(PeopleBirth)%12=2 + then '狗' + when YEAR(PeopleBirth)%12=3 + then '猪' + when YEAR(PeopleBirth)%12=4 + then '鼠' + when YEAR(PeopleBirth)%12=5 + then '牛' + when YEAR(PeopleBirth)%12=6 + then '虎' + when YEAR(PeopleBirth)%12=7 + then '兔' + when YEAR(PeopleBirth)%12=8 + then '龙' + when YEAR(PeopleBirth)%12=9 + then '蛇' + when YEAR(PeopleBirth)%12=10 + then '马' + when YEAR(PeopleBirth)%12=11 + then '羊' + end 生肖 from People \ No newline at end of file diff --git "a/\346\235\250\345\207\214\347\277\224 22 02/\347\254\224\350\256\260/2022-09-18-\347\206\237\346\202\211\350\257\255\346\263\225.md" "b/\346\235\250\345\207\214\347\277\224 22 02/\347\254\224\350\256\260/2022-09-18-\347\206\237\346\202\211\350\257\255\346\263\225.md" new file mode 100644 index 0000000000000000000000000000000000000000..e77da7d8de17b8bfb3df1ff75ca395f36c837245 --- /dev/null +++ "b/\346\235\250\345\207\214\347\277\224 22 02/\347\254\224\350\256\260/2022-09-18-\347\206\237\346\202\211\350\257\255\346\263\225.md" @@ -0,0 +1,5 @@ +掌握了以下2个MS SQL的新语法 + +identify 识别列 + +check 检查条件 \ No newline at end of file