Answer the question
In order to leave comments, you need to log in
How to make multilevel JSON using PHP and MySQL?
What is the easiest way to generate such JSON
{
"response": {
"data": [
{
"month": "2014-07-01", // данные групируються по месяцам, а это собственно месяц
"managers": [
{
"name": "Dixie Powell",
"deal_count": 23,
"sale_sum": 2853
},
...
]
},
...
]
}
}
SELECT
DATE_FORMAT(`date`, '%Y-%m-01') AS `Месяц`
FROM
manager_sales
GROUP BY YEAR(`date`) , MONTH(`date`)
ORDER BY `Месяц`
Answer the question
In order to leave comments, you need to log in
SELECT
DATE_FORMAT(`date`, '%Y-%m') AS months,
`manager_name`,
COUNT(`manager_name`) AS deal_count,
SUM(`sale_total`) AS sale_sum
FROM `manager_sales`
GROUP BY DATE_FORMAT(`date`, '%Y-%m'), `manager_name`
ORDER BY `date`, `manager_name`
Load dynamically on click I recently encountered. Killed two days for a solution, but did not find it. Decided in this way. In the end, not every time you need to look at the statistics for the past months, so it makes no sense to get the data right away. And cycles are somehow tough, especially if there is a lot of data.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question