Skip to content
Advertisement

Convert result of CASE Expression to a number in Oracle SQL

I have the following select query. I want to convert it from string into a number. If I wrap a TO_NUMBER around the case expression, I get

expression must have same datatype as corresponding expression

error.

How can I get Final_Grade to be numeric?

Thank you!

Advertisement

Answer

Well, ' ' is not a number, so better figure out what to do. I would suggest NULL:

Actually, I prefer:

Or perhaps even more safely:

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