我在执行此查询时遇到问题
SELECT
*
FROM
(SELECT
A.ItemNo, A.EquipmentID, A.AssetAccountCode, A.Descrip,
B.Condition, B.[Year],
C.Brand, C.Model, C.TechnicalSpecs,
D.[Type], D.Criticallity, D.[Status],
(CONVERT(VARCHAR(4), d.YearInstalled, 127)) AS Yearinstalled
FROM
tbl_Masterlist A
JOIN
tbl_Condition B ON A.EquipmentID = B.EquipmentID
JOIN
tbl_TechnicalSpecification C ON b.EquipmentID = c.EquipmentID
JOIN
tbl_Status D On c.EquipmentID = d.EquipmentID) src
PIVOT
(MAX(CONDITION) FOR YEAR IN ([2014], [2015], [2016])) piv
问题是输出不显示或执行时间太长(我试图等待30分钟并且仍在执行)。
任何想法为什么会发生这种情况?我该怎么办。
我猜测原因是由于4个表的记录。每个表有16000条记录,其中一些ID是空白的。