CREATE TABLE `t` (
`t1` INT(10) NULL DEFAULT NULL,
`t2` DATE NULL DEFAULT NULL,
`t3` INT(10) NULL DEFAULT NULL
)
INSERT INTO `t` (`t1`, `t2`, `t3`) VALUES
(1, '2012-04-19', 100),
(2, '2012-04-18', 200),
(3, '2012-04-18', 300),
(4, '2012-04-19', 150);
and request:
select sum(t3), t2 from t where t2=(select t2 from t where t3 = (select max(t3) from t))
the result gives us 500 and 2012-04-18, i.e. amount and date
or check this:
select t1, sum(t3), t2 from t where t2=(select t2 from t where t3 = (select max(t3) from t)) group by t1
source
share