7

可能重复:
无法绑定多部分标识符

这是我不想工作的查询。

它说:无法绑定多部分标识符“dbo.RunSequenceBatch.RunSequenceBatchName”。

您能否提一些建议?

提前致谢!!!:)

SELECT '30 May' AS [Date],
[RunSeq].[RunSequenceBatchName] AS [Batch Job Name] ,
RunSeqCat.CategoryDescription AS [Development Name] ,
[Systems].SystemName AS [System Area] ,
CAST((SUM(DumpSM37_Env3.Duration) / 60) AS NUMERIC(10, 2)) AS [Duration (mins)] 
FROM [dbo].[RunSequenceBatch] AS RunSeq 
LEFT JOIN DumpSM37_Env3 ON ([RunSeq].[RunSequenceBatchName] =  DumpSM37_Env3.[Job] 
AND DumpSM37_Env3.[ImportDate] BETWEEN  '30 May 2012 00:00:00' AND '30 May 2012 23:59:59'), 
[dbo].[RunSequenceType] AS RunSeqType, 
[dbo].[RunSequenceFrequency] AS RunSeqFrequency, 
RunSequenceCategory AS RunSeqCat, Category, [Systems]  
WHERE RunSeq.Status = 'Active' 
AND RunSeqFrequency.RunSequenceBatchID  = RunSeq.RunSequenceBatchID 
AND RunSeq.RunSequenceTypeID = RunSeqType.RunSequenceTypeID 
AND RunSeqCat.CategoryDescription = Category.Description 
AND Category.SystemArea = [Systems].SystemID 
AND DumpSM37_Env3.[Duration] > 0 
AND RunSeq.RunSequenceTypeID = 1 
AND RunSeqCat.RunSequenceBatchID = RunSeq.RunSequenceBatchID  
GROUP BY dbo.RunSequenceBatch.RunSequenceBatchName, DumpSM37_Env3.WorkerProcessID, 
ORDER BY [RunSeqFrequency].[Frequency] ASC, 
[RunSeqFrequency].[StartTime] ASC
4

1 回答 1

14

基本上,您的表名不匹配。

在你的FROM你有:

FROM [dbo].[RunSequenceBatch] AS RunSeq 

你在别名[dbo].[RunSequenceBatch]换句话说,你说从现在开始,[dbo].[RunSequenceBatch]将被称为RunSeq

但是在您的情况下,GROUP BY您不会使用别名来引用它。因为查询中唯一公开的名称中的别名,dbo.RunSequenceBatch无法绑定。

改变

GROUP BY dbo.RunSequenceBatch.RunSequenceBatchName

GROUP BY RunSeq.RunSequenceBatchName

你会没事的。

于 2012-05-30T07:31:33.143 回答