I’m not sure what has happened exactly.
I have a query which gets all sales made in a week that has slightly malfunctioned breaking up a week in to 2, here is the query…
SELECT
ROUND(SUM(sell_price), 2) AS sell_price,
ROUND(SUM(buy_price/100*20), 2) AS fees,
ROUND(SUM(buy_price), 2) AS buy_price,
ROUND(SUM(sell_price/100*80 - buy_price), 2) AS margin,
time
FROM order_items
GROUP BY WEEK(FROM_UNIXTIME(time), 1)
ORDER BY WEEK(FROM_UNIXTIME(time), 1) DESC
This outputs the following
Sell Price Fees Buy Price Margin Date
44.01 4.46 22.30 12.91 31-12-2012
464.00 46.58 232.90 138.36 27-12-2012
313.82 31.80 159.01 92.06 10-12-2012
669.91 62.13 310.67 225.26 03-12-2012
265.88 25.57 127.84 84.87 02-12-2012
208.58 15.78 78.88 87.98 24-11-2012
176.90 16.32 81.59 59.93 01-01-2013
As you can see from the table you have the week beginning from the 31/12/12 being cut off from sales made in 2013, the sales are also not being returned in descending order as sales from 2013 should be displayed at the top of the table.
The table returned should look something like…
Sell Price Fees Buy Price Margin Date
220.2 20.78 103.90 72.84 31-12-2012
464.00 46.58 232.90 138.36 27-12-2012
313.82 31.80 159.01 92.06 10-12-2012
669.91 62.13 310.67 225.26 03-12-2012
265.88 25.57 127.84 84.87 02-12-2012
208.58 15.78 78.88 87.98 24-11-2012
Maybe this will work for you: