select嵌套问题SELECT TOP 10TA001+-+TA002 单据编号,TA006 产品品号,TA034 产品品名,TA035 产品规格,TA
select嵌套问题
SELECT TOP 10
TA001+'-'+TA002 单据编号,
TA006 产品品号,
TA034 产品品名,
TA035 产品规格,
TA015 预计产量,
TA017 已生产量,
ISNULL((SELECT SUM(TC014) FROM SFCTC
INNER JOIN SFCTB ON TB001=TC001 AND TB002=TC002
WHERE TC004=TA001 AND TC005=TA002 AND TB005='M01' AND TB008='1000'),0) 转移数量,
(SELECT TB005/(MD006/MD007) FROM (
SELECT TB003 PH,MIN(TB005) FROM MOCTB A
INNER JOIN INVMB ON MB001=TB003 WHERE MB042='1' GROUP BY TB003)
INNER JOIN BOMMD ON MD003=A.TB003 WHERE MD001=TA006) 已领料量
FROM MOCTA
WHERE TA011 IN('1','2','3') AND TA001 IN('511','521') AND SUBSTRING(TA006,1,2) NOT IN('MB','MT','ML','MD','MX')
ORDER BY TA001+TA002 asc
提示以下错误信息:Msg 156, Level 15, State 1, Line 9
关键字 'INNER' 附近有语法错误。
[最优解释]SELECT TOP 10
TA001+'-'+TA002 单据编号,
TA006 产品品号,
TA034 产品品名,
TA035 产品规格,
TA015 预计产量,
TA017 已生产量,
ISNULL((SELECT SUM(TC014) FROM SFCTC
INNER JOIN SFCTB ON TB001=TC001 AND TB002=TC002
WHERE TC004=TA001 AND TC005=TA002 AND TB005='M01' AND TB008='1000'),0) 转移数量,
(SELECT TB005/(MD006/MD007) FROM (
SELECT TB003 PH,MIN(TB005) FROM MOCTB A INNER JOIN INVMB ON MB001=TB003 WHERE MB042='1' GROUP BY TB003) T--这里少了个别名。汗。这东西嵌套的好多啊你
INNER JOIN BOMMD ON MD003=A.TB003 WHERE MD001=TA006) 已领料量
FROM MOCTA
WHERE TA011 IN('1','2','3') AND TA001 IN('511','521') AND SUBSTRING(TA006,1,2) NOT IN('MB','MT','ML','MD','MX')
ORDER BY TA001+TA002 asc
[其他解释]SELECT TOP 10
TA001+'-'+TA002 单据编号,
TA006 产品品号,
TA034 产品品名,
TA035 产品规格,
TA015 预计产量,
TA017 已生产量,
ISNULL((SELECT SUM(TC014) FROM SFCTC
INNER JOIN SFCTB ON TB001=TC001 AND TB002=TC002
WHERE TC004=TA001 AND TC005=TA002 AND TB005='M01' AND TB008='1000'),0) 转移数量,
(SELECT TB005/(MD006/MD007) FROM (
SELECT TB003 PH,MIN(TB005) FROM MOCTB A INNER JOIN INVMB ON MB001=TB003 WHERE MB042='1' GROUP BY TB003) A
INNER JOIN BOMMD ON MD003=A.TB003 WHERE MD001=TA006) 已领料量
FROM MOCTA
WHERE TA011 IN('1','2','3') AND TA001 IN('511','521') AND SUBSTRING(TA006,1,2) NOT IN('MB','MT','ML','MD','MX')
ORDER BY TA001+TA002 asc
还是有错,能说详细点吗?最好带点解释,我对嵌套还是很模糊Msg 8155, Level 16, State 2, Line 1
没有为 'A' 的列 2 指定任何列。
Msg 207, Level 16, State 1, Line 9
列名 'TB003' 无效。
Msg 207, Level 16, State 1, Line 9
列名 'TB005' 无效。