0
How can I sort recorded database records as SWEEP. I tried unsuccessfully the code below. How can I format to get the expected order?
SELECT *, CAST(representantes_vendas.valor AS INT) FROM representantes_vendas
INNER JOIN representantes ON representantes_vendas.codigo_repre = representantes.codigo
ORDER BY representantes_vendas.valor DESC
//Resultado Obtido
2017 99.948,54
2017 99,27
2017 91,10
2017 97.757,23
//Resultado esperado
2017 99.948,54
2017 97.757,23
2017 99,27
2017 91,10
You can convert to number (float or decimal for example) to sort. For this you can use
cast
orconvert
: https://dev.mysql.com/doc/refman/5.7/en/cast-functions.html Now why use a fieldvarchar
to store a numerical value?– Ricardo Pontual
I will check the possibility of changing the field to float.
– denis
Read this post https://answall.com/questions/288357/comort-do-a-soma-dos-values-of-a-columna-sum%C3%A9m-o-decimal-no-php? noredirect=1#comment588048_288357
– user60252