Home > database >  Small white: about how to implement the query statistics
Small white: about how to implement the query statistics

Time:10-11

Company let me do a statistical personnel on duty according to the current number of days before the time of the function to return a list of the number of duty to the front-end thought it should be easy to
But look at the SQL database table don't know how to implement, and specific tables for bosses, solution 1, I illustrated the following
The CREATE TABLE ` gongshu_schedule ` (
` id ` int (11), NOT NULL AUTO_INCREMENT,
` fk_ai_id ` int (11) the DEFAULT NULL COMMENT 'intelligent template foreign keys,
` boss_id ` varchar (255) COLLATE utf8_bin DEFAULT NULL COMMENT 'leadership id',
` boss_name ` varchar (255) COLLATE utf8_bin DEFAULT NULL COMMENT 'leadership name,
` morn_id ` varchar (255) COLLATE utf8_bin DEFAULT NULL COMMENT 'day shift personnel id',
` morn_name ` varchar (255) COLLATE utf8_bin DEFAULT NULL COMMENT 'day shift staff name,
` even_id ` varchar (255) COLLATE utf8_bin DEFAULT NULL COMMENT 'night shift staff id,
` even_name ` varchar (255) COLLATE utf8_bin DEFAULT NULL COMMENT 'night shift staff name,
` onduty_id ` varchar (255) COLLATE utf8_bin DEFAULT NULL COMMENT 'on duty personnel id',
` onduty_name ` varchar (255) COLLATE utf8_bin DEFAULT NULL COMMENT 'on duty personnel name,
` driver_id ` varchar (255) COLLATE utf8_bin DEFAULT NULL COMMENT 'BeiQin driver id',
` driver_name ` varchar (255) COLLATE utf8_bin DEFAULT NULL COMMENT 'BeiQin driver name,
` p_id ` int (11) the DEFAULT NULL COMMENT 'change id',
` duty_time ` timestamp NULL DEFAULT NULL COMMENT 'on duty date,
` state ` tinyint (4) the DEFAULT NULL COMMENT 'status, 0: enabled, 1: disable',
` is_delete ` tinyint (4) the DEFAULT NULL,
` create_time ` timestamp NULL DEFAULT NULL,
` update_time ` timestamp NULL DEFAULT NULL,
PRIMARY KEY (` id `),
The UNIQUE KEY ` duty_time ` (` duty_time `)
31) ENGINE=InnoDB AUTO_INCREMENT=DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='calendar';

The data I have provided some
INSERT INTO ` gongshu_schedule ` VALUES (1, 1, '196412415421799906', 'li-ming lu', '1142132201843671', 'cao jie', '0106310349841958', 'Yang', '0230223035315017', 'Xie Wenhu', '083223276624134528', 'Zhang Tianen, NULL,' 2020-06-01 00:00:00, 0, 0, 'the 2020-06-02 18:36:41', '2020-06-02 18:36:41');
INSERT INTO ` gongshu_schedule ` VALUES (2, 2, '1142132201843671', 'cao jie', '0450451606856055', 'li chao', '0344452237833568', 'Chen Dongyue', 'manager8843', 'Yang Xi', '196412415421799906', 'li-ming lu, NULL,' 2020-06-02 00:00:00, 0, 0, 'the 2020-06-02 18:36:41', '2020-06-02 18:36:41');
INSERT INTO ` gongshu_schedule ` VALUES (3, 1, '196412415421799906', 'li-ming lu', '1142132201843671', 'cao jie', '0106310349841958', 'Yang', '0230223035315017', 'Xie Wenhu', '083223276624134528', 'Zhang Tianen, NULL,' 2020-06-03 00:00:00, 0, 0, 'the 2020-06-02 18:36:41', '2020-06-02 18:36:41');
INSERT INTO ` gongshu_schedule ` VALUES (4, 2, '1142132201843671', 'cao jie', '0450451606856055', 'li chao', '0344452237833568', 'Chen Dongyue', 'manager8843', 'Yang Xi', '196412415421799906', 'li-ming lu, NULL,' 2020-06-04 00:00:00, 0, 0, 'the 2020-06-02 18:36:41', '2020-06-02 18:36:41');
INSERT INTO ` gongshu_schedule ` VALUES (5, 1, '196412415421799906', 'li-ming lu', '1142132201843671', 'cao jie', '0106310349841958', 'Yang', '0230223035315017', 'Xie Wenhu', '083223276624134528', 'Zhang Tianen, NULL,' 2020-06-05 00:00:00, 0, 0, 'the 2020-06-02 18:36:41', '2020-06-02 18:36:41');
INSERT INTO ` gongshu_schedule ` VALUES (6, 2, '1142132201843671', 'cao jie', '0450451606856055', 'li chao', '0344452237833568', 'Chen Dongyue', 'manager8843', 'Yang Xi', '196412415421799906', 'li-ming lu, NULL,' 2020-06-06 00:00:00, 0, 0, 'the 2020-06-02 18:36:41', '2020-06-02 18:36:41');
INSERT INTO ` gongshu_schedule ` VALUES (7, 1, '196412415421799906', 'li-ming lu', '1142132201843671', 'cao jie', '0106310349841958', 'Yang', '0230223035315017', 'Xie Wenhu', '083223276624134528', 'Zhang Tianen, NULL,' 2020-06-07 00:00:00, 0, 0, 'the 2020-06-02 18:36:41', '2020-06-02 18:36:41');
INSERT INTO ` gongshu_schedule ` VALUES (8, 2, '1142132201843671', 'cao jie', '0450451606856055', 'li chao', '0344452237833568', 'Chen Dongyue', 'manager8843', 'Yang Xi', '196412415421799906', 'li-ming lu, NULL,' 2020-06-08 00:00:00, 0, 0, 'the 2020-06-02 18:36:41', '2020-06-02 18:36:41');
INSERT INTO ` gongshu_schedule ` VALUES (9, 1, '196412415421799906', 'li-ming lu', '1142132201843671', 'cao jie', '0106310349841958', 'Yang', '0230223035315017', 'Xie Wenhu', '083223276624134528', 'Zhang Tianen, NULL,' 2020-06-09 00:00:00, 0, 0, 'the 2020-06-02 18:36:41', '2020-06-02 18:36:41');
INSERT INTO ` gongshu_schedule ` VALUES (10, 2, '1142132201843671', 'cao jie', '0450451606856055', 'li chao', '0344452237833568', 'Chen Dongyue', 'manager8843', 'Yang Xi', '196412415421799906', 'li-ming lu, NULL,' 2020-06-10 00:00:00, 0, 0, 'the 2020-06-02 18:36:41', '2020-06-02 18:36:41');
INSERT INTO ` gongshu_schedule ` VALUES (11, 1, '196412415421799906', 'li-ming lu', '1142132201843671', 'cao jie', '0106310349841958', 'Yang', '0230223035315017', 'Xie Wenhu', '083223276624134528', 'Zhang Tianen, NULL,' 2020-06-11 00:00:00, 0, 0, 'the 2020-06-02 18:36:41', '2020-06-02 18:36:41');
INSERT INTO ` gongshu_schedule ` VALUES (12, 2, '1142132201843671', 'cao jie', '0450451606856055', 'li chao', '0344452237833568', 'Chen Dongyue', 'manager8843', 'Yang Xi', '196412415421799906', 'li-ming lu, NULL,' 2020-06-12 00:00:00, 0, 0, 'the 2020-06-02 18:36:41', '2020-06-02 18:36:41');
INSERT INTO ` gongshu_schedule ` VALUES (13, 1, '196412415421799906', 'li-ming lu', '1142132201843671', 'cao jie', '0106310349841958', 'Yang', '0230223035315017', 'Xie Wenhu', '083223276624134528', 'Zhang Tianen, NULL,' 2020-06-13 00:00:00, 0, 0, 'the 2020-06-02 18:36:41', '2020-06-02 18:36:41');
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related