--
-- Структура таблицы `test`
--
CREATE TABLE IF NOT EXISTS `test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` text NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`views` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
--
-- Дамп данных таблицы `test`
--
INSERT INTO `test` (`id`, `title`, `created_at`, `views`) VALUES
(1, 'Test 1', '2017-03-09 13:34:19', 436),
(2, 'Test 2', '2017-03-01 13:34:19', 21),
(3, 'Title 3', '2017-03-01 13:38:07', 23),
(4, 'Title 4', '2017-03-03 13:38:07', 66);
SELECT created_at, SUM(views)
FROM `test`
WHERE created_at >= DATE('2017-02-01')
AND created_at <= DATE('2017-03-18')
GROUP BY DATE(created_at)