CREATE TABLE IF NOT EXISTS executions (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
build_id int(10) NOT NULL DEFAULT 0,
tester_id int(10) UNSIGNED DEFAULT NULL,
execution_date datetime DEFAULT NULL,
STATUS char(1) DEFAULT NULL,
project_id int(10) UNSIGNED NOT NULL DEFAULT 0,
test_id int(10) UNSIGNED NOT NULL DEFAULT 0,
platform_id int(10) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (id)
);
INSERT INTO executions (id, build_id, tester_id, execution_date, STATUS, project_id, test_id, platform_id) VALUES
(1753, 36, 8, '2011-11-14 14:13:31', 'f', 3347, 1544, 159),
(1750, 36, 7, '2011-11-14 14:12:35', 'b', 3347, 1544, 159),
(1745, 36, 8, '2011-11-14 14:10:43', 'p', 3347, 1544, 159),
(1752, 36, 7, '2011-11-14 14:12:51', 'p', 3347, 1547, 159),
(1746, 36, 8, '2011-11-14 14:10:51', 'f', 3347, 1547, 159),
(1747, 36, 8, '2011-11-14 14:12:12', 'p', 3347, 1550, 159),
(1748, 36, 8, '2011-11-14 14:12:26', 'p', 3347, 1553, 159),
(1751, 36, 8, '2011-11-14 14:12:43', 'p', 3347, 1556, 159),
(1749, 36, 8, '2011-11-14 14:12:33', 'f', 3347, 1556, 159),
(1699, 36, 7, '2011-11-09 11:06:07', 'p', 3347, 1897, 136),
(1701, 36, 7, '2011-11-09 11:06:45', 'p', 3347, 1897, 137),
(1713, 36, 7, '2011-11-09 12:23:48', 'p', 3347, 1897, 152),
(1720, 36, 7, '2011-11-09 12:24:55', 'p', 3347, 1897, 153),
(1721, 36, 7, '2011-11-09 12:25:00', 'p', 3347, 1897, 153),
(1722, 36, 7, '2011-11-09 12:25:05', 'p', 3347, 1897, 153),
(1707, 36, 7, '2011-11-09 12:22:01', 'i', 3347, 1901, 137),
(1714, 36, 7, '2011-11-09 12:23:56', 'p', 3347, 1901, 152),
(1723, 36, 7, '2011-11-08 12:25:14', 'p', 3347, 1901, 153),
(1708, 36, 7, '2011-11-09 12:22:06', 'b', 3347, 1904, 137),
(1715, 36, 7, '2011-11-09 12:24:04', 'p', 3347, 1904, 152),
(1724, 36, 7, '2011-11-08 12:25:21', 'p', 3347, 1904, 153),
(1709, 36, 7, '2011-11-09 12:22:10', 'p', 3347, 1907, 137),
(1716, 36, 7, '2011-11-09 12:24:12', 'p', 3347, 1907, 152),
(1725, 36, 7, '2011-11-08 12:25:30', 'p', 3347, 1907, 153),
(1710, 36, 7, '2011-11-09 12:22:16', 'f', 3347, 1910, 137),
(1717, 36, 7, '2011-11-09 12:24:20', 'p', 3347, 1910, 152),
(1726, 36, 7, '2011-11-08 12:25:47', 'p', 3347, 1910, 153),
(1711, 36, 7, '2011-11-09 12:22:23', 'p', 3347, 1913, 137),
(1718, 36, 7, '2011-11-09 12:24:25', 'p', 3347, 1913, 152)
Chciłbym zwrócić zapytaniem tabelę [Dzień - ilość]
--Dzień--------Status:s---------Status:p------ Status:b------Razem
2011-11-14--------1----------------2--------------1------------4
2011-11-09--------5----------------7--------------3------------15
2011-11-08--------4----------------1--------------3------------8
Wartości przykładowe
Częściowo udaje mi się wydobyć dane zapytaniem, ale nie do końca jet to to co chce.
SELECT execution_date, STATUS, count(*) AS quantity FROM (SELECT * FROM (SELECT id,DATE_FORMAT(execution_date,GET_FORMAT(DATE,'ISO')) AS 'execution_date', STATUS, project_id, test_id, platform_id FROM (SELECT id,execution_date, STATUS, project_id, test_id, platform_id FROM executions GROUP BY project_id, platform_id, execution_date, STATUS HAVING project_id = '3347' ORDER BY test_id ASC) AS temp GROUP BY execution_date, test_id, platform_id) AS temp2 GROUP BY execution_date, test_id, platform_id) AS Temp3 GROUP BY execution_date, STATUS