在 order by 旁边使用 case 时出错

A error while using case next to order by

代码应该给我 table ordered after if value 'isOnline' == 1 then 'onlineTime', if 'isOnline' == 0 then onlineTime + current自 1970 年 1 月 1 日午夜 UTC 以来的毫秒数(isOnline 是 TINYINT,onlineTime 是 BIGINT)

SELECT * FROM onlinecountertable 
ORDER BY 
    CASE `isOnline`
        WHEN 0 THEN `onlineTime`
        WHEN 1 THEN (onlineTime + (ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000))
        ELSE `onlineTime` 
    END
    DESC LIMIT 30 

但是如果我使用上面的查询,它会给我这个错误:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ELSE -1
    END)
    DESC LIMIT 30 LIMIT 0, 25' at line 6

替换这个

    WHEN 1 THEN (onlineTime + (ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000))

由此

    WHEN 1 THEN (onlineTime + ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000))

干杯;-)