日期:2014-05-16 浏览次数:20762 次
CREATE TABLE `test` ( `Id` int(11) NOT NULL auto_increment, `title` varchar(255) default NULL COMMENT '标题', `clicktime` int(11) default NULL COMMENT '点击次数', `mtype` int(11) default NULL COMMENT '类型', `goal` tinyint(3) default NULL COMMENT '分数', `create_date` date NOT NULL default '2012-01-01' COMMENT '日期', PRIMARY KEY (`Id`), KEY `IND_TYPE` (`mtype`,`goal`,`clicktime`,`create_date`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
select a.* from ( select t1.*,(select count(Id)+1 from test where mtype=t1.mtype and clicktime>t1.clicktime ) as group_id from test t1 where t1.create_date='2012-04-29' ) a where a.group_id<=10