I have a table which looks something like this
sell_price double buy_price double time int(11)
31.5 20.5 1353755931 (2012-11-27)
20 10.5 1353755235 (2012-11-27)
40 30 1353752531 (2012-11-26)
50 25 1353751237 (2012-11-26)
40 10 1353745609 (2012-11-25)
And I am trying to group all values to get the sales for each day of the week, the desired table should look like the following:
sell_price double buy_price double time int(11)
51.5 30.5 1353755931 (2012-11-27)
90 55 1353755931 (2012-11-26)
40 10 1353755931 (2012-11-25)
I tried the following query but I seem to have a problem with grouping
SELECT sell_price, buy_price, time
FROM sales
GROUP BY DAY(time)
ORDER BY time DESC
The above query returns only 1 row
31.5 20.5 1353755931
What is the correct way to achieve this?
SELECT DATE(FROM_UNIXTIME(time)) time,
SUM(sell_price),
SUM(buy_price)
FROM tableName
GROUP BY DATE(FROM_UNIXTIME(time))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With