Search code examples
t-sqldecimallatitude-longitude

Lat and Long sorting Cast decimal


I am trying to figure out why I am unable to return a longitude field by order descending.

When I use the following leaves some records out of order? It isnt picking up the max value.

select cast(LONGITUDE as decimal(12,8)) from long order by LONGITUDE desc

Output:

enter image description here

Thanks


Solution

  • Not sure why, but I'd try

    Order By 1 desc 
    

    So ordered them by the casted value not the uncasted one.