任何人都可以指出是什麼原因造成我獲得「ORDER BY CASE ......」爲了使無效表達BY子句
無效表達ORDER BY子句(不包含在聚合函數或GROUP BY子句)
有關以下查詢的錯誤?這是在火鳥2.5。
SELECT COUNT(*) AS total,
CASE WHEN YR BETWEEN 1990 AND 1995 THEN '1990-1995'
WHEN YR BETWEEN 1996 AND 2000 THEN '1996-2000'
WHEN YR BETWEEN 2001 AND 2005 THEN '2001-2005'
ELSE '2005-2017' END AS vehicle_year
FROM bb_history
GROUP BY 2
ORDER BY CASE WHEN YR BETWEEN 1990 AND 1995 THEN 1
WHEN YR BETWEEN 1996 AND 2000 THEN 2
WHEN YR BETWEEN 2001 AND 2005 THEN 3
ELSE 4 END
有分組後沒有'yr'列。要麼包括年選擇或修改您的訂單 – GurV
'訂購2'應該是現在就可以了 – GurV
@GurwinderSingh謝謝! – Phil