Skip to content
Advertisement

Alias for a mysql case statement

I would like to set an alias for the case statement in the following query. The query works fine but the last column header shows as the case statement in full. You can have a look at what I mean at dbfiddle. I am trying to get the difference between the current salary at a row and the next salary found for that employee in a list of employees.

When i try to place an alias as end as nextTotalSalary the query won’t execute. Error is “Select is not valid at this position for this server version ..”

How can i set an alias for the third column?

Advertisement

Answer

You can use AS. For example:

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