这是表格:
CREATE TABLE `incidencias` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`impact` int(10) NOT NULL,
`date` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1
我需要按“影响”分组并获取每个的最近日期
谢谢
应该是这样的:
SELECT * FROM incidencias group by impact order by date desc
用这个:
SELECT * FROM incidencias GROUP BY impact ORDER BY date DESC
应该是这样的:
SELECT * FROM incidencias GROUP BY Impact ORDER BY date DESC
SELECT Impact,MAX (date) from incidencias GROUP BY Impact
这应该有效。
select max(date) from incidencias group by impact;