I have the following query..
SELECT
TIME(date_time)
FROM
login_attempts
WHERE
DATE_FORMAT(DATE(date_time), '%d-%m-%Y') = DATE_FORMAT('2016-08-09', '%d-%m-%Y')
AND login_successful = 1
Which returns the following times from the database..
TIME(date_time)
---------------
09:08:14
09:08:36
10:08:12
10:08:29
10:08:39
11:08:52
11:08:54
How can I get the median time of the times returned from this query?
EDIT - Here is the information to build a table in SQLFiddle.
CREATE TABLE `login_attempts` (
`id` int(11) UNSIGNED NOT NULL,
`username` varchar(100) NOT NULL,
`ip_address` varbinary(128) NOT NULL,
`date_time` datetime DEFAULT NULL,
`login_successful` tinyint(1) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `login_attempts` (`id`, `username`, `ip_address`, `date_time`, `login_successful`) VALUES
(1, 'test@test.com', '127.0.0.1', now(), 1),
(2, 'test', '127.0.0.1', now(), 0),
(3, 'test@test.com', '127.0.0.1', now(), 1),
(4, 'test', '127.0.0.1', now(), 0),
(5, ' test@test.com', '127.0.0.1', now(), 1);
ALTER TABLE `login_attempts`
ADD PRIMARY KEY (`id`);
ALTER TABLE `login_attempts`
MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;