1
说我有一个表:MySQL的GroupWise的限制查询
create table foo (
corp_id int not null,
tdate date not null,
sec_id int unsigned not null,
amount int unsigned not null,
primary key (corp_id, sec_id, tdate)
);
下面的查询将返回的金额列的总和所有corp_id的和日期:
select corp_id, tdate, sum(amount) from foo group by corp_id, tdate;
哪有我现在限制此查询仅返回每个corp_id的前5个最新日期?