Reputation: 307
I have a mysql table like this with these sample data
I write this query
SELECT SUM(amount),DATE(date) FROM outgoings WHERE outgoings_type_id = '1'GROUP BY amount
I got the output like this
I want it not like this but like this(I did some photoshop edit to above one!)
The only change is I want the summation of amounts which are on same date..Others are normal way..Is it possible or not with some changes to my query..?
Upvotes: 1
Views: 44
Reputation: 11307
Try this, you do your sum(amount) and group by date.
SELECT SUM(amount),DATE(date) FROM outgoings WHERE outgoings_type_id = '1'GROUP BY DATE(date)
Your aggregate (sum or whatever) will be grouped by the date field then.
Also, I don't think you need to do DATE(date)
SELECT SUM(amount),date FROM outgoings WHERE outgoings_type_id = '1'GROUP BY date
Upvotes: 3