I have a complicated mysql table, like:
staff type value date
a cash 10 2013-02-17
b efpos 5 2013-02-16
c voucher 20 2013-02-16
a cash 10 2013-02-16
b efpos 5 2013-02-16
c voucher 20 2013-02-15
a cash 10 2013-02-15
b efpos 5 2013-02-15
c voucher 20 2013-02-14
How can I get a table like this?
staff cash efpos voucher total date
a sum sum sum sum(cash, efpos, voucher) 2013-02-16
b sum sum sum sum(cash, efpos, voucher) 2013-02-16
c sum sum sum sum(cash, efpos, voucher) 2013-02-16
It means I want to get the separated sum for each type using group by staff and date, and also with a total for this three types.
This should work.
However, you can’t get the date when using aggregate functions. Nor would it make sense to do so, since you are not using group by on the date, but the staff instead.