I have a table called orders
this table contains all the information we need.
I'll just list the columns we need for the query:
purchase_price
(always contains the total amount paid for the order)pay_method
((int) when1
it means the fullpurchase_price
was paid for in cash, when3
it meanspurchase_price
was only paid partially in cash, other values mean other paying means so ignore them.)cash_paid
(when thepay_method
is3
this column contains the amount of cash paid for the order, note that this is not the total price, it's just the part ofpurchase_price
that was paid for in cash. Whenpay_method
is NOT3
this field's value is0
date
((datetime)simply the date+time on which the order was placed)
The idea is pretty simple. we need to get the total amount of cash payed grouped by day. But we found this a pretty hard task.
PS: I'm playing around with this problem in PHP using MySQL, so it's alright to use multiple queries and/or use some PHP script.
See Question&Answers more detail:os