時,這是不允許的我有下面的腳本由於標題中的錯誤而停止工作。有人可以提供一些幫助嗎?子查詢返回多個值。當子查詢如下
SELECT DISTINCT TOP 100 PERCENT
Locs.lCustomerGroupPK, Locs.lCustomerID, Locs.Customer_Group_Name, Locs.Customer_Name, Locs.Location_Name, TY.ThisYearsSales,
(SELECT ThisYearsSales
FROM dbo.Vw_Level_3_Sales_This_Year
WHERE (lLocationID = Locs.lLocationID2 OR lLocationID = Locs.llocationid)
AND (Current_Read_Date = TY.Current_Read_Date - 364) AND (ThisYearsSales <= 400)
) AS LastYearsSales,
TY.Current_Read_Date - 1 AS Current_Read_Date INTO #tmplocationlflsales
FROM dbo.Vw_Level_3_Sales_This_Year AS TY
INNER JOIN dbo.vw_locations_Like_For_Like_Previous AS Locs
ON TY.lLocationID = Locs.llocationid OR TY.lLocationID = Locs.lLocationID2
WHERE (TY.ThisYearsSales <= 400)
AND (TY.Current_Read_Date = @RecordDate)
AND TY.ThisYearsSales IS NOT NULL
AND (SELECT ThisYearsSales
FROM dbo.Vw_Level_3_Sales_This_Year
WHERE (lLocationID = Locs.lLocationID2 OR lLocationID = Locs.llocationid)
AND (Current_Read_Date = TY.Current_Read_Date - 364)
AND (ThisYearsSales <= 400)
) IS NOT NULL
ORDER BY Locs.Customer_Group_Name, Locs.Customer_Name, Locs.Location_Name, Current_Read_Date
請下次正確格式化您的SQL查詢 – LittleBobbyTables 2012-07-25 12:59:34
第一次使用。我如何正確格式化? – 2012-07-25 13:00:32
選擇塊並點擊 K –
wildplasser
2012-07-25 13:01:32