Search code examples
sqlcastingsyntax-errorproject

Incorrect syntax near 'cast', expected 'AS'- SQL Project


I am watching this video from Alex Freburg: https://www.youtube.com/watch?v=qfyynHBFOsM.

At 33.43 mins he has done some code on the server, the exact I have copied but I get this error message:

Incorrect syntax near 'CAST', expected 'AS'

The code I have tried to run is this:

Select location, MAX(CAST(total_deaths) AS int)) AS TotalDeathCount
From [Portfolio Project]..CovidDeaths$
group by location
order by TotalDeathCount desc

Any help would be appreciated.

I tried a variety of things but not sure why it is not working like the video above.


Solution

  • There's an extra closing right paren ())

    MAX(CAST(total_deaths) AS int)) 
    

    should be

    MAX(CAST(total_deaths AS int))