1

Error in MySQL Syntax for a Case State

 2 years ago
source link: https://www.codesd.com/item/error-in-mysql-syntax-for-a-case-state.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Error in MySQL Syntax for a Case State

advertisements

I'm working on a baseball projections system, and I'm trying to have two different formulas based on games started.

This is my current error:

ERROR 1064 (42000): 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 '(ROUND( COALESCE(IP1,0) * .5 + COALESCE(IP2,0) * .1 + 60 )) D( COALESCE(IP1,0) *' at line 6

And this is what my code looks like:

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;


You're opening a ( before Case and you're never closing it you should remove the ( anyway (or close it after End


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK