我试图弄清楚为什么第 22 行和第 25 行的第二个 BEGIN/END 块错误。两种情况的 END。我错过了什么?另外我怎么能做一个查询而不是两个块?
BEGIN
SELECT
l.partNum AS [Part Number]
,l.pricePerUOM AS [Price Per UOM]
,l.uom AS [UOM]
,SUM(CONVERT(DECIMAL(18,12), l.totalCostPerWS/l.pricePerUOM)) AS [Quantity/WS] INTO #temp
FROM tbl_step s
JOIN tbl_line l ON s.stepId = l.stepId
WHERE s.revisionId = @revisionId
AND ISNUMERIC(l.totalCostPerWS) > 0
AND ISNUMERIC(l.pricePerUOM) > 0
GROUP BY l.partNum, l.pricePerUOM, l.uom
END
BEGIN
SELECT
l.partNum AS [Part Number]
,l.pricePerUOM AS [Price Per UOM]
,l.uom AS [UOM]
,CASE
WHEN l.partNum >=2 AND l.uom = 'liter' THEN (SELECT CONVERT(DECIMAL(18,12),[Quantity/WS] * 1000)
END AS [Converted]
,CASE
WHEN l.uom = 'milliliter' THEN (SELECT CONVERT(DECIMAL(18,12),[Quantity/WS] + l.pricePerUOM)
END AS [Qnty/WS + Price per UOM]
FROM #temp
JOIN tbl_line l ON s.stepId = l.stepId
JOIN tbl_step s ON l.stepId = s.stepId
WHERE
ISNUMERIC(l.totalCostPerWS) > 0
AND ISNUMERIC(l.pricePerUOM) > 0
GROUP BY l.partNum, l.pricePerUOM, l.uom
END
谢谢你的帮助。F