group by调整

master
c1769 2 years ago
parent 632ce81b2a
commit e5767d9f50

@ -11,7 +11,7 @@
Target Server Version : 80025 (8.0.25) Target Server Version : 80025 (8.0.25)
File Encoding : 65001 File Encoding : 65001
Date: 16/08/2023 17:20:53 Date: 17/08/2023 16:54:51
*/ */
SET NAMES utf8mb4; SET NAMES utf8mb4;
@ -1179,7 +1179,7 @@ CREATE TABLE `sys_log` (
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
INDEX `token`(`token` ASC) USING BTREE, INDEX `token`(`token` ASC) USING BTREE,
INDEX `create_time`(`create_time` ASC) USING BTREE INDEX `create_time`(`create_time` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2824 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '行为日志' ROW_FORMAT = DYNAMIC; ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '行为日志' ROW_FORMAT = DYNAMIC;
-- ---------------------------- -- ----------------------------
-- Records of sys_log -- Records of sys_log
@ -1195,7 +1195,7 @@ CREATE TABLE `sys_log_text` (
`params` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '请求参数', `params` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '请求参数',
`result` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '结果', `result` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '结果',
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 19 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;
-- ---------------------------- -- ----------------------------
-- Records of sys_log_text -- Records of sys_log_text
@ -1483,6 +1483,6 @@ INSERT INTO `yszk_transfer` VALUES (1, '2023-08-13 12:20:27', '2023-08-13 12:20:
-- View structure for user_integral -- View structure for user_integral
-- ---------------------------- -- ----------------------------
DROP VIEW IF EXISTS `user_integral`; DROP VIEW IF EXISTS `user_integral`;
CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `user_integral` AS select `t10`.`user_id` AS `user_id`,`t10`.`class_id` AS `class_id`,`t10`.`total_integral` AS `integral`,row_number() OVER (ORDER BY `t10`.`total_integral` desc ) AS `integral_order` from (select `t9`.`user_id` AS `user_id`,sum((`t9`.`integral` + `t9`.`ext_integral`)) AS `total_integral`,`t9`.`class_id` AS `class_id` from (select `t2`.`user_id` AS `user_id`,`t3`.`mode` AS `MODE`,`t2`.`class_id` AS `class_id`,sum((50 - (30 * (1 - `t3`.`mode`)))) AS `integral`,sum(distinct `t1`.`flow_id`) AS `flow_id_sum`,(case when (sum(distinct `t1`.`flow_id`) > 14) then (100 * (`t3`.`mode` + 1)) else 0 end) AS `ext_integral` from ((`financings` `t1` join `user_examinations` `t2` on((`t1`.`instance_id` = `t2`.`instance_id`))) join `examinations` `t3` on((`t2`.`examination_id` = `t3`.`id`))) where ((`t1`.`financing_status` = 9) and (`t3`.`mode` is not null) and (`t3`.`type` = 0)) group by `t2`.`user_id`,`t3`.`mode`) `t9` group by `t9`.`user_id`) `t10`; CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `user_integral` AS select `t10`.`user_id` AS `user_id`,max(`t10`.`class_id`) AS `class_id`,max(`t10`.`total_integral`) AS `integral`,row_number() OVER (ORDER BY `t10`.`total_integral` desc ) AS `integral_order` from (select `t9`.`user_id` AS `user_id`,sum((`t9`.`integral` + `t9`.`ext_integral`)) AS `total_integral`,max(`t9`.`class_id`) AS `class_id` from (select `t2`.`user_id` AS `user_id`,`t3`.`mode` AS `MODE`,`t2`.`class_id` AS `class_id`,sum((50 - (30 * (1 - `t3`.`mode`)))) AS `integral`,sum(distinct `t1`.`flow_id`) AS `flow_id_sum`,(case when (sum(distinct `t1`.`flow_id`) > 14) then (100 * (`t3`.`mode` + 1)) else 0 end) AS `ext_integral` from ((`financings` `t1` join `user_examinations` `t2` on((`t1`.`instance_id` = `t2`.`instance_id`))) join `examinations` `t3` on((`t2`.`examination_id` = `t3`.`id`))) where ((`t1`.`financing_status` = 9) and (`t3`.`mode` is not null) and (`t3`.`type` = 0)) group by `t2`.`user_id`,`t3`.`mode`) `t9` group by `t9`.`user_id`) `t10`;
SET FOREIGN_KEY_CHECKS = 1; SET FOREIGN_KEY_CHECKS = 1;

@ -429,9 +429,9 @@ getTeacherClassExaminationScoreChart
```` ````
select select
t2.id examination_id, t2.id examination_id,
t2.name examination_name, max(t2.name) examination_name,
t3.class_id, t3.class_id,
t4.name class_name, max(t4.name) class_name,
avg(t1.total_scores) total_scores avg(t1.total_scores) total_scores
from user_examinations t1 from user_examinations t1
join examinations t2 on t1.examination_id = t2.id join examinations t2 on t1.examination_id = t2.id

Loading…
Cancel
Save