我有兩列,它們是按另一列中的值計算的。計算列上的自定義排序
CASE
WHEN ACT.TotalScore > 850 THEN 'Cok Basarili'
WHEN ACT.TotalScore <= 850 AND ACT.TotalScore > 700 THEN 'Basarili'
ELSE 'Basarisiz' END as Basari,
CASE
WHEN ACT.TotalScore > 850 THEN 'rgba(123,192,67,1)'
WHEN ACT.TotalScore <= 850 AND ACT.TotalScore > 700 THEN 'rgba(253,244,152,1)'
ELSE 'rgba(243,119,54,1)' END as Renk
他們計算成功,並根據他們的點實際分配一種顏色。
ON GROUP BY
我用同樣的CASE WHEN
太
總產量(與其他的選擇元素ADN where子句等,並沒有ORDER BY)
+---------------+--------------+---------------------+
| DenetimSayisi | Basari | Renk |
+---------------+--------------+---------------------+
| 35 | Cok Basarili | rgba(123,192,67,1) |
| 60 | Basarisiz | rgba(243,119,54,1) |
| 29 | Basarili | rgba(253,244,152,1) |
+---------------+--------------+---------------------+
我想根據做出的客戶訂單'伯薩里' 列,並試圖此
ORDER BY CASE
WHEN ACT.TotalScore > 850 THEN 2
WHEN ACT.TotalScore <= 850 AND ACT.TotalScore > 700 THEN 1
ELSE 3 END
給出該錯誤
Msg 8127, Level 16, State 1, Line 36
Column "Activity.TotalScore" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
Msg 8127, Level 16, State 1, Line 37
Column "Activity.TotalScore" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
Msg 8127, Level 16, State 1, Line 37
Column "Activity.TotalScore" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
我不知道還有什麼我可以嘗試或我該如何解決這個問題。
你能顯示你所有的查詢嗎? – gofr1