我有以下脚本由于标题错误而停止工作。有人可以提供一些帮助吗?
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