案例陈述的MySQL语法错误

时间:2015-06-11 14:09:01

标签: mysql case

我正在制作一个棒球投影系统,我正试图根据比赛开始有两种不同的公式。

这是我当前的错误:

  

错误1064(42000):您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在'附近使用正确的语法(ROUND(COALESCE(IP1,0)* .5 + COALESCE(IP2,0)* .1 + 60))   D(第6行的COALESCE(IP1,0)*'

这就是我的代码:

CREATE TABLE player_ip_2015
AS 
SELECT playerID
    ,CASE
        WHEN (b.GS > 5)
            THEN (ROUND( COALESCE(IP1,0) * .5 + COALESCE(IP2,0) * .1 + 60 ))
            ELSE (ROUND( COALESCE(IP1,0) * .5 + COALESCE(IP2,0) * .1 + 20 ))
            END
            AS IP
FROM (SELECT * FROM (SELECT DISTINCT playerID FROM pitching_pos) b
        LEFT JOIN (SELECT playerID AS playerID1, (IPOuts/3) AS IP1 FROM pitching_pos
                WHERE yearID = "2014") b1
                ON b.playerID = b1.playerID1
        LEFT JOIN (SELECT playerID AS playerID2, (IPOuts/3) AS IP2 FROM pitching_pos
                WHERE yearID = "2013") b2
                ON b.playerID = b2.playerID2) b
GROUP BY playerID
ORDER BY IP DESC;

2 个答案:

答案 0 :(得分:0)

您在(之前打开Case并且您永远不会关闭它 你应该删除((或在End

之后关闭它)

答案 1 :(得分:0)

IP1的价值是多少? 其次,您对问题的标题与您报告的错误不符。 第三,你还有一个额外的(在声明的FROM部分。

检查您的代码。