From 26c32ff12ba4a1c09e79444a4d1cfc9a152b3e75 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=86=B7=E8=B0=83?= <3084898776@qq.com>
Date: Fri, 19 Jul 2024 08:58:32 +0800
Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E8=80=83sql?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 38 ++
.idea/$PROJECT_FILE$ | 11 +
.idea/.gitignore | 8 +
.idea/encodings.xml | 8 +
.idea/inspectionProfiles/Project_Default.xml | 5 +
.idea/misc.xml | 30 ++
.idea/qaplug_profiles.xml | 465 +++++++++++++++++++
pom.xml | 17 +
src/sql/zhuangao6rk22.sql | 129 +++++
src/sql/zhuangao6rk2sql.sql | 17 +
10 files changed, 728 insertions(+)
create mode 100644 .gitignore
create mode 100644 .idea/$PROJECT_FILE$
create mode 100644 .idea/.gitignore
create mode 100644 .idea/encodings.xml
create mode 100644 .idea/inspectionProfiles/Project_Default.xml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/qaplug_profiles.xml
create mode 100644 pom.xml
create mode 100644 src/sql/zhuangao6rk22.sql
create mode 100644 src/sql/zhuangao6rk2sql.sql
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/.idea/$PROJECT_FILE$ b/.idea/$PROJECT_FILE$
new file mode 100644
index 0000000..58b7e3e
--- /dev/null
+++ b/.idea/$PROJECT_FILE$
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..63574ec
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..8d66637
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..f25c597
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+ {
+ "isMigrated": true
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/qaplug_profiles.xml b/.idea/qaplug_profiles.xml
new file mode 100644
index 0000000..3dfd21f
--- /dev/null
+++ b/.idea/qaplug_profiles.xml
@@ -0,0 +1,465 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..b5f1236
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,17 @@
+
+
+ 4.0.0
+
+ com.bwie
+ day_02
+ 1.0-SNAPSHOT
+
+
+ 17
+ 17
+ UTF-8
+
+
+
diff --git a/src/sql/zhuangao6rk22.sql b/src/sql/zhuangao6rk22.sql
new file mode 100644
index 0000000..cf05d27
--- /dev/null
+++ b/src/sql/zhuangao6rk22.sql
@@ -0,0 +1,129 @@
+/*
+ Navicat Premium Data Transfer
+
+ Source Server : 129.211.0.187
+ Source Server Type : MySQL
+ Source Server Version : 50736
+ Source Host : 129.211.0.187:3306
+ Source Schema : zhuangao6rk22
+
+ Target Server Type : MySQL
+ Target Server Version : 50736
+ File Encoding : 65001
+
+ Date: 19/07/2024 08:50:57
+*/
+
+SET NAMES utf8mb4;
+SET
+FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for stu_cou
+-- ----------------------------
+DROP TABLE IF EXISTS `stu_cou`;
+CREATE TABLE `stu_cou`
+(
+ `sc_id` int(11) NOT NULL AUTO_INCREMENT,
+ `c_id` int(11) NULL DEFAULT NULL COMMENT '课程ID',
+ `s_id` int(11) NULL DEFAULT NULL COMMENT '学生ID',
+ PRIMARY KEY (`sc_id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 18 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of stu_cou
+-- ----------------------------
+INSERT INTO `stu_cou`
+VALUES (1, 1, 1);
+INSERT INTO `stu_cou`
+VALUES (2, 1, 2);
+INSERT INTO `stu_cou`
+VALUES (3, 1, 3);
+INSERT INTO `stu_cou`
+VALUES (4, 1, 4);
+INSERT INTO `stu_cou`
+VALUES (5, 1, 5);
+INSERT INTO `stu_cou`
+VALUES (6, 2, 1);
+INSERT INTO `stu_cou`
+VALUES (7, 2, 3);
+INSERT INTO `stu_cou`
+VALUES (8, 2, 5);
+INSERT INTO `stu_cou`
+VALUES (9, 2, 7);
+INSERT INTO `stu_cou`
+VALUES (10, 2, 8);
+INSERT INTO `stu_cou`
+VALUES (11, 2, 9);
+INSERT INTO `stu_cou`
+VALUES (12, 3, 1);
+INSERT INTO `stu_cou`
+VALUES (13, 3, 2);
+INSERT INTO `stu_cou`
+VALUES (14, 3, 3);
+INSERT INTO `stu_cou`
+VALUES (15, 3, 4);
+INSERT INTO `stu_cou`
+VALUES (16, 3, 9);
+INSERT INTO `stu_cou`
+VALUES (17, 3, 8);
+
+-- ----------------------------
+-- Table structure for t_course
+-- ----------------------------
+DROP TABLE IF EXISTS `t_course`;
+CREATE TABLE `t_course`
+(
+ `c_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '课程编号',
+ `c_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '课程名',
+ PRIMARY KEY (`c_id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '课程表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of t_course
+-- ----------------------------
+INSERT INTO `t_course`
+VALUES (1, '语文');
+INSERT INTO `t_course`
+VALUES (2, '数学');
+INSERT INTO `t_course`
+VALUES (3, '英语');
+
+-- ----------------------------
+-- Table structure for t_student
+-- ----------------------------
+DROP TABLE IF EXISTS `t_student`;
+CREATE TABLE `t_student`
+(
+ `s_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '学生编号',
+ `s_name` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '学生姓名',
+ `sex` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '性别',
+ PRIMARY KEY (`s_id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '学生表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of t_student
+-- ----------------------------
+INSERT INTO `t_student`
+VALUES (1, '张三', '男');
+INSERT INTO `t_student`
+VALUES (2, '李四', '女');
+INSERT INTO `t_student`
+VALUES (3, '王五', '女');
+INSERT INTO `t_student`
+VALUES (4, '赵六', '男');
+INSERT INTO `t_student`
+VALUES (5, '天启', '男');
+INSERT INTO `t_student`
+VALUES (6, '田七', '女');
+INSERT INTO `t_student`
+VALUES (7, '周六', '男');
+INSERT INTO `t_student`
+VALUES (8, '村长', '女');
+INSERT INTO `t_student`
+VALUES (9, '薛一', '男');
+INSERT INTO `t_student`
+VALUES (10, '薛二', '男');
+
+SET
+FOREIGN_KEY_CHECKS = 1;
diff --git a/src/sql/zhuangao6rk2sql.sql b/src/sql/zhuangao6rk2sql.sql
new file mode 100644
index 0000000..b14bb40
--- /dev/null
+++ b/src/sql/zhuangao6rk2sql.sql
@@ -0,0 +1,17 @@
+-- #查询男生和女生各多少人
+SELECT sex, COUNT(*)
+FROM t_student
+GROUP BY sex;
+
+-- # 查询男生和女生分别占总人数的比例
+SELECT sex, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM t_student)
+FROM t_student
+GROUP BY sex;
+
+-- #查询每门课程下的学生总人数
+SELECT c_name,
+ COUNT(DISTINCT stu_cou.s_id) AS sumpeople
+FROM stu_cou
+ INNER JOIN t_course on stu_cou.c_id = t_course.c_id
+ INNER JOIN t_student on stu_cou.s_id = t_student.s_id
+GROUP BY c_name;