Всем привет. Написал такой Селект:
SELECT
YEAR(action_date) AS `Year`,
NULL AS `Month`,
NULL AS `Day`,
SUM(qty*price) AS `Total`
FROM actions
GROUP BY `Year` , `Month` , `Day`
UNION
SELECT
YEAR(action_date) AS `Year`,
MONTH(action_date) AS `Month`,
NULL AS `Day`,
SUM(qty*price) AS `Total`
FROM actions
GROUP BY `Year` , `Month` , `Day`
UNION
SELECT
YEAR(action_date) AS `Year`,
MONTH(action_date) AS `Month`,
DATE(action_date) AS `Day`,
SUM(qty*price) AS `Total`
FROM actions
GROUP BY `Year` , `Month` , `Day`
ORDER BY `Year`, `Month`, `Day`
Результатом которого, выборка ниже:
'2015', NULL, NULL, '181974.00000'
'2015', '7', NULL, '88319.00000'
'2015', '7', '2015-07-25', '35467.00000'
'2015', '7', '2015-07-26', '17149.00000'
'2015', '7', '2015-07-28', '8293.00000'
'2015', '7', '2015-07-29', '19760.00000'
'2015', '7', '2015-07-30', '7650.00000'
Подскажите, как можно заменить заменить NULL на пустые значения? И как можно выполнять модификации над выборкой, после ORDER BY? Заранее спасибо.