diff --git "a/18\351\231\210\351\271\217/\344\275\234\344\270\232/SQLQuery2.sql" "b/18\351\231\210\351\271\217/\344\275\234\344\270\232/SQLQuery2.sql" new file mode 100644 index 0000000000000000000000000000000000000000..8a36b8713637c80ce1ccf41efbaeb6eca5befa3d --- /dev/null +++ "b/18\351\231\210\351\271\217/\344\275\234\344\270\232/SQLQuery2.sql" @@ -0,0 +1,54 @@ +--1. 查询出武汉地区所有的员工信息,要求显示部门名称以及员工的详细资料 +select * from People +join Department on People.DepartmentId = Department.DepartmentId +where PeopleAddress ='武汉'; + +--2. 查询出武汉地区所有的员工信息,要求显示部门名称,职级名称以及员工的详细资料 +select * from People +join Department on People.DepartmentId = Department.DepartmentId +join [rank] on people.departmentid=[rank].rankid +where PeopleAddress ='武汉'; + +--3. 根据部门分组统计员工人数,员工工资总和,平均工资,最高工资和最低工资。 +select DepartmentName,COUNT(*) 员工人数, SUM(PeopleSalary) 工资总和, AVG(PeopleSalary) 平均工资, MAX(PeopleSalary) 最大工资,MIN(PeopleSalary) 最小工资 from People +join Department on People.DepartmentId = Department.DepartmentId +group by DepartmentName; + +--4. 根据部门分组统计员工人数,员工工资总和,平均工资,最高工资和最低工资,平均工资在10000 以下的不参与统计,并且根据平均工资降序排列。 +select DepartmentName,COUNT(*) 员工人数, SUM(PeopleSalary) 工资总和, AVG(PeopleSalary) 平均工资, MAX(PeopleSalary) 最大工资,MIN(PeopleSalary) 最小工资 from People +join Department on People.DepartmentId = Department.DepartmentId +group by DepartmentName +having AVG(PeopleSalary)>=10000 +order by AVG(PeopleSalary) desc; + + + + +--5. 根据部门名称,然后根据职位名称,分组统计员工人数,员工工资总和,平均工资,最高工资和最低工资 +select DepartmentName,RankName ,[Rank].RankId 职位等级 , COUNT(*) 员工人数,SUM(PeopleSalary) 工资总和, AVG(PeopleSalary) 平均工资, MAX(PeopleSalary) 最大工资,MIN(PeopleSalary) 最小工资 from people +join department on People.DepartmentId = Department.DepartmentId +join [Rank] on People.RankId = [Rank].RankId +group by DepartmentName,RankName,[Rank].RankId + + +--6.查询出巨蟹 6.22--7.22 的员工信息 +select * from people where +(MONTH(PeopleBirth)=6 and DAY(PeopleBirth)>=22) or +(MONTH(PeopleBirth)=7 and DAY(PeopleBirth)<=22) + +--7.查询所有员工信息,添加一列显示属相(鼠,牛,虎,兔,龙,蛇,马,羊,猴,鸡,狗,猪) +select * , +case when datepart(YY,PeopleBirth)%12=0 then'鼠' +when datepart(YY,PeopleBirth)%12=1 then'牛' +when datepart(YY,PeopleBirth)%12=2 then'虎' +when datepart(YY,PeopleBirth)%12=3 then'兔' +when datepart(YY,PeopleBirth)%12=4 then'龙' +when datepart(YY,PeopleBirth)%12=5 then'蛇' +when datepart(YY,PeopleBirth)%12=6 then'马' +when datepart(YY,PeopleBirth)%12=7 then'羊' +when datepart(YY,PeopleBirth)%12=8 then'猴' +when datepart(YY,PeopleBirth)%12=9 then'鸡' +when datepart(YY,PeopleBirth)%12=10 then'狗' +when datepart(YY,PeopleBirth)%12=11 then'猪' +end as 属相 +from people ; \ No newline at end of file diff --git "a/18\351\231\210\351\271\217/\347\254\224\350\256\260/9-16\347\254\254\344\272\214\346\254\241\350\257\276\346\237\245\350\257\242.md" "b/18\351\231\210\351\271\217/\347\254\224\350\256\260/9-16\347\254\254\344\272\214\346\254\241\350\257\276\346\237\245\350\257\242.md" new file mode 100644 index 0000000000000000000000000000000000000000..ef141a6232d91f3a0b742cf666e5fe4a776c4eb2 --- /dev/null +++ "b/18\351\231\210\351\271\217/\347\254\224\350\256\260/9-16\347\254\254\344\272\214\346\254\241\350\257\276\346\237\245\350\257\242.md" @@ -0,0 +1,19 @@ +## 绗簩娆¤鏌ヨ + +--淇濈暀灏忔暟鐐瑰悗2浣 + +--round(灏忔暟,淇濈暀浣嶆暟) + +--convert 02154.13200 decimal(5,2):淇濈暀灏忔暟鍚2浣嶏紝鏈夋晥鏁板瓧鎬诲叡鏄5 + +--convert鍜宑ast 鍙互寮哄埗杞崲鏁版嵁绫诲瀷 + +--count(*):绌哄间篃缁熻 count(瀛楁)锛氬綋鍓嶅瓧娈电殑绌哄间笉缁熻 + +--鍒犻櫎鏁版嵁 +delete from 琛ㄥ悕 where 鍒楀悕='' + +--鍒犻櫎 +--drop 鍒犻櫎鏁村紶琛 +--truncate鍒犻櫎鏁村紶琛紝琛ㄨ繕鍦 + diff --git a/README.en.md b/README.en.md deleted file mode 100644 index ac31e94d7051efb27325dd6be9b67641b85572e6..0000000000000000000000000000000000000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# SQL杩涢樁 - -#### Description -11 - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md deleted file mode 100644 index 1c4b0e7c62868161068647925213862187205184..0000000000000000000000000000000000000000 --- a/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# SQL杩涢樁 - -#### 浠嬬粛 -11 - -#### 杞欢鏋舵瀯 -杞欢鏋舵瀯璇存槑 - - -#### 瀹夎鏁欑▼ - -1. xxxx -2. xxxx -3. xxxx - -#### 浣跨敤璇存槑 - -1. xxxx -2. xxxx -3. xxxx - -#### 鍙備笌璐$尞 - -1. Fork 鏈粨搴 -2. 鏂板缓 Feat_xxx 鍒嗘敮 -3. 鎻愪氦浠g爜 -4. 鏂板缓 Pull Request - - -#### 鐗规妧 - -1. 浣跨敤 Readme\_XXX.md 鏉ユ敮鎸佷笉鍚岀殑璇█锛屼緥濡 Readme\_en.md, Readme\_zh.md -2. Gitee 瀹樻柟鍗氬 [blog.gitee.com](https://blog.gitee.com) -3. 浣犲彲浠 [https://gitee.com/explore](https://gitee.com/explore) 杩欎釜鍦板潃鏉ヤ簡瑙 Gitee 涓婄殑浼樼寮婧愰」鐩 -4. [GVP](https://gitee.com/gvp) 鍏ㄧО鏄 Gitee 鏈鏈変环鍊煎紑婧愰」鐩紝鏄患鍚堣瘎瀹氬嚭鐨勪紭绉寮婧愰」鐩 -5. Gitee 瀹樻柟鎻愪緵鐨勪娇鐢ㄦ墜鍐 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 灏侀潰浜虹墿鏄竴妗g敤鏉ュ睍绀 Gitee 浼氬憳椋庨噰鐨勬爮鐩 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)