I have a table like
CREATE TABLE sales
(`id` int, `date` date, `amount` int(4))
;
insert into sales values (1, '2012-09-01', 200),
(2, '2012-09-01', 300),
(3, '2012-09-02', 400),
(4, '2012-09-02', 500),
(5, '2012-09-02', 600)
I wish to retrieve a row showing the sales for today, and the sales for yesterday
like
Date Today Total sales Yesterday Sales
2012-09-02 1500 500
Tried using something like
SELECT id, date, sum(amount) FROM sales
GROUP BY date;
But it returns the sales day wise. I understand that can be done programmatically, but is there a better way to directly retrieve it from the DB?
http://sqlfiddle.com/#!2/0ef6a/18