I am doing a versioning system so that every time you edit a page, the old page is still kept but the new page is shown insted. I have that working find but when I am trying to list the pages I am having problems getting a query to do it. I have a table like this: [code]CREATE TABLE `pages` ( `id` varchar(25) NOT NULL default '', `date` datetime NOT NULL default '0000-00-00 00:00:00', `title` varchar(25) NOT NULL default '', `content` mediumtext NOT NULL, PRIMARY KEY (`id`,`date`), FULLTEXT KEY `Search` (`title`,`content`) );[/code] I want to count all of the ID's with the most recent date. I have tried: [code]SELECT COUNT(*) as total FROM pages GROUP BY date HAVING MAX(date)[/code] returns 0 [code]SELECT COUNT(MAX(date)) FROM pages GROUP BY date[/code] but that returns this error [code]#1111 - Invalid use of group function[/code] Does anyone know of a solution?