我有一個柱(* Purchasetype *),用戶標識在視頻表purchasetype是方含一些如何值0,1,2,3,4,..等我通過userid
來得到兩個和這些值的順序。MySQL查詢使用條件內部總和
對於前:sum (purchasetype) order by userid
但我想這樣
if purchasetype= 0 then its value is 0.99
if purchasetype =1 or 20 then its value is 3.99
if purchasetype = 3 or 13or 22 then its value is 9.99
等。下面是完整列表
0 ,17= 0.99
1,20=3.99
2=6.99
3,13,22=9.99
4,5,6,7,8,,10,11,12=0.00
14=19.99
15,23=39.99
16,24=59.99
18,21=01.99
19=02.99
else
19.99
我要總結的purchasetype
所有值與他們的替代值(上面給出的)order by userid
我們可以把條件的MySQL sum()
函數內;如果可能的話,請給我的解決方案,可能是這將解決我的問題
非常感謝你的工作 – user1648175
@ user1648175高興,這是工作。如果答案有幫助,那麼一定要通過左側的複選標記將其標記爲已接受。它也會幫助未來的遊客。 – Taryn