我对 AdventureWorks2012 数据库有以下查询
SELECT productid,
productname,
unitprice,
CASE
WHEN unitprice < 20.0 THEN 'LOW'
WHEN unitprice < 40.0 THEN 'MEDIUM'
WHEN unitprice >= 40.0 THEN 'HIGH'
END pricerange
FROM Production.Products
ORDER BY
CASE
WHEN pricerange < 'LOW' THEN 1
WHEN pricerange < 'MEDIUM' THEN 2
WHEN pricerange >= 'HIGH' THEN 3
END ASC
GO
ORDER BY
语句后发生SELECT
,但无法访问 pricerange 列名?我假设SELECT
语句中的 pricerange 是在调用之后计算ORDER BY
的?为什么是这样?