这是我不希望的查询。
它说:不能绑定多部分标识符“ 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
FROM [dbo].[RunSequenceBatch] AS RunSeq
您是别名,[dbo].[RunSequenceBatch]也就是说,从现在开始,[dbo].[RunSequenceBatch]将被称为RunSeq
[dbo].[RunSequenceBatch]
RunSeq
但是在您中,GROUP BY您不会使用别名来引用它。因为别名在查询中唯一公开的名称中,dbo.RunSequenceBatch所以无法绑定。
GROUP BY
dbo.RunSequenceBatch
改变
GROUP BY dbo.RunSequenceBatch.RunSequenceBatchName
到
GROUP BY RunSeq.RunSequenceBatchName
而且您会没事的。