SELECT
`param`,
`brand`,
`screen`,
COUNT(`id`) AS `requests`,
SUM(`duration`) AS `duration_sum`,
AVG(`duration`) AS `duration_avg`,
COUNT(DISTINCT `device_id`) AS `devices`
FROM `statistic_prolonged`
WHERE (
`date_start` BETWEEN '2018-01-01 00:00:00' AND '2018-12-31 23:59:59.999999' OR
`date_end` BETWEEN '2018-01-01 00:00:00' AND '2018-12-31 23:59:59.999999')
AND `action` = 'OPEN_SECTION'
GROUP BY `param`, `system_brandname`.`name`, `system_screensize`.`name`
{
"data":
[
{
"id": 14838494,
"action": "PLAY_CHANNEL",
"param": "3057",
"params": "Music Box TV",
"device_id": 11807,
"date_end": "2017-01-01 00:26:55",
"date_start": "2017-01-01 00:26:52",
"duration": 3527000,
"city_id": 2096,
"screen": 40,
"brand": "JVC",
}
]
}