0
我已經創建了我所插入另一個SELECT語句並標記該聲明與「別名」另一場插入子裏面查看
的觀點得到了成功執行,但試圖火從視圖中選擇語句時的視圖查詢(選擇視圖*),它拋出的
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression
錯誤現在,我意識到這個錯誤到來的原因。這是因爲內部選擇查詢返回多於一行。我不能進入TOP 1,因爲我需要有不止一行。
ALTER VIEW [dbo].[TestView_new]
AS
SELECT TOP (100) PERCENT
dbo.DataRepository.PeriodStatus ,
dbo.DataRepository.TimesheetName ,
dbo.DataRepository.TimesheetLineClass ,
dbo.DataRepository.TimesheetLineClassUID ,
dbo.MSP_EpmResource_UserView.ResourceName ,
dbo.MSP_EpmProject_UserView.ProjectName AS ProjectName ,
(SELECT MSP_EpmProject_UserView.ProjectName
FROM dbo.MSP_EpmProject_UserView
LEFT JOIN dbo.DataRepository ON dbo.MSP_EpmProject_UserView.[ProjectUID] = dbo.DataRepository.[ProjectUID]
WHERE LTRIM(RTRIM(dbo.DataRepository.[ProjectUID])) IS NOT NULL
OR LTRIM(RTRIM(dbo.DataRepository.[ProjectUID])) <> '') AS ProjectName2 ,
FROM dbo.DataRepository
INNER JOIN dbo.MSP_TimesheetActual ON dbo.DataRepository.TimesheetLineUID = dbo.MSP_TimesheetActual.TimesheetLineUID
LEFT OUTER JOIN dbo.MSP_EpmResource_UserView ON dbo.DataRepository.ResourceUID = dbo.MSP_EpmResource_UserView.ResourceUID
LEFT OUTER JOIN dbo.MSP_EpmProject_UserView ON dbo.DataRepository.ProjectUID = dbo.MSP_EpmProject_UserView.ProjectUID
我的問題:有什麼辦法可以解決錯誤嗎?
顯示您的查詢和數據庫結構 –
你如何顯示數據庫結構。它相當大!我可以顯示查詢。 –
@juergend:我已更新問題 –