1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
| --------------
SET AUTOCOMMIT = 0
--------------
--------------
START TRANSACTION
--------------
--------------
DROP DATABASE IF EXISTS `base`
--------------
--------------
CREATE DATABASE `base`
DEFAULT CHARACTER SET `latin1`
DEFAULT COLLATE `latin1_general_ci`
--------------
--------------
DROP TABLE IF EXISTS `w_daphne`
--------------
--------------
CREATE TABLE `w_daphne`
( `id` integer unsigned not null auto_increment primary key,
`date` date not null,
`debut` time not null,
`fin` time not null
) ENGINE=InnoDB
DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
INSERT INTO `w_daphne` (`date`,`debut`, `fin`) VALUES
('2018-05-14', '09:00:00', '21:00:00'),
('2018-05-15', '08:00:00', '10:00:00'),
('2018-05-16', '09:00:00', '18:00:00'),
('2018-05-17', '09:00:00', '18:00:00'),
('2018-05-18', '09:00:00', '18:00:00'),
('2018-05-19', '09:00:00', '18:00:00'),
('2018-05-20', '09:00:00', '18:00:00'),
('2018-05-21', '09:00:00', '18:00:00'),
('2018-05-22', '09:00:00', '18:00:00'),
('2018-05-23', '09:00:00', '18:00:00'),
('2018-05-24', '09:00:00', '18:00:00'),
('2018-05-25', '09:00:00', '18:00:00'),
('2018-05-26', '09:00:00', '18:00:00'),
('2018-05-27', '09:00:00', '18:00:00'),
('2018-05-28', '09:00:00', '18:00:00'),
('2018-05-29', '09:00:00', '18:00:00'),
('2018-05-30', '09:00:00', '18:00:00'),
('2018-05-31', '09:00:00', '18:00:00'),
('2018-06-01', '09:00:00', '18:00:00'),
('2018-06-02', '09:00:00', '18:00:00'),
('2018-06-03', '09:00:00', '18:00:00'),
('2018-06-04', '09:00:00', '18:00:00'),
('2018-06-05', '09:00:00', '18:00:00'),
('2018-06-06', '09:00:00', '18:00:00'),
('2018-06-07', '09:00:00', '18:00:00'),
('2018-06-08', '09:00:00', '18:00:00'),
('2018-06-09', '09:00:00', '18:00:00'),
('2018-06-10', '09:00:00', '18:00:00'),
('2018-06-11', '09:00:00', '18:00:00'),
('2018-06-12', '09:00:00', '18:00:00'),
('2018-06-13', '09:00:00', '18:00:00'),
('2018-06-14', '09:00:00', '18:00:00'),
('2018-06-15', '09:00:00', '18:00:00'),
('2018-06-16', '09:00:00', '18:00:00'),
('2018-01-01', '07:00:00', '11:30:00'),
('2018-01-15', '07:00:00', '11:00:00'),
('2018-03-15', '18:00:00', '24:00:00'),
('2018-03-16', '00:00:00', '04:00:00')
--------------
--------------
select * from `w_daphne`
--------------
+----+------------+----------+----------+
| id | date | debut | fin |
+----+------------+----------+----------+
| 1 | 2018-05-14 | 09:00:00 | 21:00:00 |
| 2 | 2018-05-15 | 08:00:00 | 10:00:00 |
| 3 | 2018-05-16 | 09:00:00 | 18:00:00 |
| 4 | 2018-05-17 | 09:00:00 | 18:00:00 |
| 5 | 2018-05-18 | 09:00:00 | 18:00:00 |
| 6 | 2018-05-19 | 09:00:00 | 18:00:00 |
| 7 | 2018-05-20 | 09:00:00 | 18:00:00 |
| 8 | 2018-05-21 | 09:00:00 | 18:00:00 |
| 9 | 2018-05-22 | 09:00:00 | 18:00:00 |
| 10 | 2018-05-23 | 09:00:00 | 18:00:00 |
| 11 | 2018-05-24 | 09:00:00 | 18:00:00 |
| 12 | 2018-05-25 | 09:00:00 | 18:00:00 |
| 13 | 2018-05-26 | 09:00:00 | 18:00:00 |
| 14 | 2018-05-27 | 09:00:00 | 18:00:00 |
| 15 | 2018-05-28 | 09:00:00 | 18:00:00 |
| 16 | 2018-05-29 | 09:00:00 | 18:00:00 |
| 17 | 2018-05-30 | 09:00:00 | 18:00:00 |
| 18 | 2018-05-31 | 09:00:00 | 18:00:00 |
| 19 | 2018-06-01 | 09:00:00 | 18:00:00 |
| 20 | 2018-06-02 | 09:00:00 | 18:00:00 |
| 21 | 2018-06-03 | 09:00:00 | 18:00:00 |
| 22 | 2018-06-04 | 09:00:00 | 18:00:00 |
| 23 | 2018-06-05 | 09:00:00 | 18:00:00 |
| 24 | 2018-06-06 | 09:00:00 | 18:00:00 |
| 25 | 2018-06-07 | 09:00:00 | 18:00:00 |
| 26 | 2018-06-08 | 09:00:00 | 18:00:00 |
| 27 | 2018-06-09 | 09:00:00 | 18:00:00 |
| 28 | 2018-06-10 | 09:00:00 | 18:00:00 |
| 29 | 2018-06-11 | 09:00:00 | 18:00:00 |
| 30 | 2018-06-12 | 09:00:00 | 18:00:00 |
| 31 | 2018-06-13 | 09:00:00 | 18:00:00 |
| 32 | 2018-06-14 | 09:00:00 | 18:00:00 |
| 33 | 2018-06-15 | 09:00:00 | 18:00:00 |
| 34 | 2018-06-16 | 09:00:00 | 18:00:00 |
| 35 | 2018-01-01 | 07:00:00 | 11:30:00 |
| 36 | 2018-01-15 | 07:00:00 | 11:00:00 |
| 37 | 2018-03-15 | 18:00:00 | 24:00:00 |
| 38 | 2018-03-16 | 00:00:00 | 04:00:00 |
+----+------------+----------+----------+
--------------
select date_format(`date` - interval 15 day,'%Y-%m') as periode,
cast(sum(timediff(`fin`,`debut`)) as time) as total
from w_daphne
group by periode
order by periode desc
--------------
+---------+-----------+
| periode | total |
+---------+-----------+
| 2018-06 | 09:00:00 |
| 2018-05 | 279:00:00 |
| 2018-04 | 14:00:00 |
| 2018-03 | 04:00:00 |
| 2018-02 | 06:00:00 |
| 2017-12 | 08:30:00 |
+---------+-----------+
--------------
COMMIT
--------------
--------------
SET AUTOCOMMIT = 1
--------------
Appuyez sur une touche pour continuer... |
Partager