Skip to content
Advertisement

SQL syntax error inside CAST with case statement

I want to list positive and negative bank_transfers from my DB. To do so I’m using below query:

But it gives me an error syntax error at or near ")". I guess it comes from the CAST so where should I close the parentheses?

Advertisement

Answer

You don’t even need those casts. You’re not casting into any type (unless sum_expenses and sum_revenue are your custom types).

Edit: If you want to cast to integer:

Or use cast(... as integer).

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement