主题:[讨论]这个sql语句有啥问题?
(SELECT a.品号 AS ph, a.对方中心 AS dfzx, a.减少数量 AS sl, b.bzsl AS bzsl
FROM (SELECT 对方中心, 品号, SUM(减少数量) AS 减少数量
FROM 减少数量表
WHERE 中心名称 = '铸造' AND 对方中心 <> '品号改动' AND 倒算 = 0
GROUP BY 对方中心, 品号) AS a LEFT JOIN
(SELECT 品号, SUM(sl) AS bzsl
FROM (SELECT 品号, 减少数量 AS sl
FROM 减少数量表
WHERE 中心名称 = '铸造' AND 对方中心 <> '品号改动' AND 倒算 = 0
UNION
SELECT 品号, 结余数量 AS sl
FROM 结余数量表
WHERE 年份 = 2008 AND 月份 = 4 AND 中心名称 = '铸造')
GROUP BY 品号) AS b ON a.品号 = b.品号) AS d
各位:
上面语句在运行时提示,关键字group附近有语法错误,到底怎会事,分析两天啦,快疯啦。
FROM (SELECT 对方中心, 品号, SUM(减少数量) AS 减少数量
FROM 减少数量表
WHERE 中心名称 = '铸造' AND 对方中心 <> '品号改动' AND 倒算 = 0
GROUP BY 对方中心, 品号) AS a LEFT JOIN
(SELECT 品号, SUM(sl) AS bzsl
FROM (SELECT 品号, 减少数量 AS sl
FROM 减少数量表
WHERE 中心名称 = '铸造' AND 对方中心 <> '品号改动' AND 倒算 = 0
UNION
SELECT 品号, 结余数量 AS sl
FROM 结余数量表
WHERE 年份 = 2008 AND 月份 = 4 AND 中心名称 = '铸造')
GROUP BY 品号) AS b ON a.品号 = b.品号) AS d
各位:
上面语句在运行时提示,关键字group附近有语法错误,到底怎会事,分析两天啦,快疯啦。