JLink
JLink

Reputation: 307

Select Query Error with Date

I have a mysql table like this with these sample data

enter image description here

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

enter image description here

I want it not like this but like this(I did some photoshop edit to above one!)

enter image description here

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

Answers (1)

mikeb
mikeb

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

Related Questions