I'm looking for a solution to get a cursive graph and extract the data right away from MYSQL to keep the memory and less code in PHP to convert it to JSON data and convert into a simple graph with DATE and values.
Maybe somebody passed trough this and can give me a solution.
I need to group by MONTH and by WEEK but based on the date from rows.
I mean:
SELECT p.code, SUM(ii.quantity) as qty, DATE_FORMAT(i.created, '%Y-%m') as date
FROM products p
LEFT JOIN inv_items ii ON p.id=ii.product_id
LEFT JOIN inv i ON i.id=ii.invid
WHERE p.id = 31910
GROUP BY YEAR(i.created), MONTH(i.created)
So the Result is:
code qty date
20418101 1 2014-07
20418101 2 2014-08
20418101 1 2014-09
20418101 4 2015-06
20418101 6 2016-05
20418101 1 2016-11
20418101 1 2017-01
20418101 1 2017-03
But what i need is to keep it cursive, i mean from (2014-07 to 2014-12) (2015-01 to 2015-12) (2016-01 to 2016-12) (2017-01 to CURDATE)
On short selection i need it to convert to week cursive view for example in 2 months (2014-07-WEEK1,2,3,4,5,6,7,8)
Is there a way to get right away from MYSQL this query without passign trough PHP to sanitize ?
I appreciate any word.
The example from the picture is an example of the real output from MYSQL what i want is to get cursive months.