(SELECT
DATE_FORMAT(created_time, '%d-%m-%Y') AS `Ngày`,
FORMAT(IFNULL(SUM(IF(object='clip',price,0)),0),0) AS `Clip`,
FORMAT(IFNULL(SUM(IF(object='book',price,0)),0),0) AS `book`,
FORMAT(IFNULL(SUM(IF(object='disk',price,0)),0),0) AS `disk`,
FORMAT(IFNULL(SUM(price),0),0) as `Total`
FROM
transaction
WHERE true
GROUP BY DATE(created_time)
ORDER BY DATE(created_time) DESC
LIMIT 0, 100)
UNION ALL
(SELECT
'Tổng hợp',
FORMAT(IFNULL(SUM(IF(object='clip',price,0)),0),0) AS `Clip`,
FORMAT(IFNULL(SUM(IF(object='book',price,0)),0),0) AS `book`,
FORMAT(IFNULL(SUM(IF(object='disk',price,0)),0),0) AS `disk`,
FORMAT(IFNULL(SUM(price),0),0) AS `Total`
FROM
transaction
ORDER BY DATE(created_time) DESC
LIMIT 0, 100);
Title:
Useful query for reporting (statistics)
Description:
(SELECT DATE_FORMAT(created_time, '%d-%m-%Y') AS `Ngày`, FORMAT(IFNULL(SUM(IF(object='clip',price,0)),0),0) AS `Clip`, ...
...
Rating:
4