我有以下要转换为视图的查询:
SELECT
PartNum,
SUM(IF(DAYOFWEEK(DeliveryDate) = '2', value, NULL)) AS 'Mon',
SUM(IF(DAYOFWEEK(DeliveryDate) = '3', value, NULL)) AS 'Tue',
SUM(IF(DAYOFWEEK(DeliveryDate) = '4', value, NULL)) AS 'Wed',
SUM(IF(DAYOFWEEK(DeliveryDate) = '5', value, NULL)) AS 'Thu',
SUM(IF(DAYOFWEEK(DeliveryDate) = '6', value, NULL)) AS 'Fri',
SUM(IF(DAYOFWEEK(DeliveryDate) = '7', value, NULL)) AS 'Sat',
SUM(IF(DAYOFWEEK(DeliveryDate) = '1', value, NULL)) AS 'Sun',
SUM(IF(DeliveryDate > DATE_ADD(CURDATE(),INTERVAL 7 DAY), value, NULL)) AS 'Future'
FROM (
SELECT PartNum, DeliveryDate , SUM(Ordered) value FROM v_archived_items_due
GROUP BY PartNum, DeliveryDate
) t
GROUP BY PartNum;
当我尝试将其另存为视图时,出现以下错误:
1349 - 视图 SELECT 在 FROM 子句中包含子查询。
查询本身可以正常工作。我如何把它变成一个视图?