Reputation: 29
Hi guys im having a problem sorting a column named "change" which is a reserved word that has a data type of "FLOAT" in the database.
tried different ways but still cant get it.
"select * from data order by CAST('change' AS SIGNED) DESC";
"select * from data order by ABS(change) DESC";
"select * from data order by ABS(change - float) DESC";
"select CAST(change as float) AS ABC* from data order by ABC DESC";
i tried lots of different combinations but still no luckenter image description here
heres a picture of my sample database thank you in advance!
Upvotes: 0
Views: 1345
Reputation: 29
As user 'sagi' suggested, using the reserved word "change", theres no need for casting or single quotes but instead back ticks work on the original question. for mac its on the left side of number 1 on the keyword. Thank you all!
Upvotes: 0
Reputation: 40481
Use back ticks
ORDER BY `CHANGE` DESC
Each RDBMS has different way of handling reserved words. MySQL uses back ticks : `
The error you got has nothing to do with casting .
Upvotes: 1