CREATE TABLE IF NOT EXISTS `accesscards` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`department` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
`entrydates` datetime NOT NULL, PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
INSERT INTO `accesscards` (`id`, `department`, `name`, `entrydates`) VALUES
(1, 'test', 't1', '2013-12-06 16:10:00'),
(2, 'test', 't1', '2013-12-06 15:10:00'),
(3, 'test', 't1', '2013-12-07 15:11:00'),
(4, 'test', 't1', '2013-12-07 15:24:00'),
(5, 'test', 't2', '2013-12-06 16:10:00'),
(6, 'test', 't2', '2013-12-06 16:25:00'),
(7, 'test', 't2', '2013-12-07 15:59:00'),
(8, 'test', 't2', '2013-12-07 16:59:00');
以上是我的查詢,我想爲每天的一個人獲取記錄。那條記錄應該有一天的最短日期。我需要全程記錄該日期時間獲取每個人每天的最短日期時間的記錄
我的預期輸出here
我使用
SELECT id, MIN(entrydates) FROM accesscards WHERE 1=1 AND name!='' GROUP BY DATE(entrydates) ORDER BY id
嘗試,但對於「T1」我的id = 1和第一排的entrydates。
請幫我一把。如果重複,則提供鏈接。
你怎麼樣所以搜索?有數百個類似的問題。 – Barmar
搜索'[mysql] [最大每個組]。 – Barmar
你看過類似的問題嗎?他們不幫你嗎? – Barmar