这是我不想工作的查询。
它说: 无法绑定多部分标识符“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
答案 0 :(得分:13)
基本上,您的表名不匹配。
在你的FROM
中:
FROM [dbo].[RunSequenceBatch] AS RunSeq
你是别名[dbo].[RunSequenceBatch]
换句话说,你说明从现在开始,[dbo].[RunSequenceBatch]
将被称为RunSeq
但在你的GROUP BY
中,你没有使用别名来引用它。由于查询中唯一公开名称中的别名,dbo.RunSequenceBatch
无法绑定。
更改
GROUP BY dbo.RunSequenceBatch.RunSequenceBatchName
到
GROUP BY RunSeq.RunSequenceBatchName
你会没事的。