这个问题在这里已经有了答案:




8年前关闭。






这是我不希望的查询。

它说:
无法绑定(bind)多部分标识符“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

最佳答案

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

在您的 FROM 中,您有:

FROM [dbo].[RunSequenceBatch] AS RunSeq

你在别名 [dbo].[RunSequenceBatch] 换句话说,你说从现在开始,[dbo].[RunSequenceBatch] 将被称为 RunSeq
但是在您的 GROUP BY 中,您没有使用别名来引用它。由于查询中唯一公开的名称中的别名,因此无法绑定(bind) dbo.RunSequenceBatch

改变
GROUP BY dbo.RunSequenceBatch.RunSequenceBatchName


GROUP BY RunSeq.RunSequenceBatchName

你会没事的。

关于sql - 无法绑定(bind)多部分标识符,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10811576/

10-15 16:28