![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
I am using a dynamic order by statement; ORDER BY CASE @sort WHEN 0 THEN CAST( COALESCE( t2.RANK, 0 ) + COALESCE( t3.RANK, 0 ) AS CHAR( 5 ) ) WHEN 1 THEN C.title WHEN 2 THEN CAST( CEILING( [dbo].[fn_calculateDistance] ( @fromLatitude, @fromLongitude, L.latitude, L.longitude ) ) AS CHAR( 9 ) ) WHEN 3 THEN ( C.locality + ' ' + C.state ) WHEN 4 THEN CAST( C.price AS CHAR( 10 ) ) END ASC The problem is with the numeric values, I have to cast them as a string, but in the results 114km obviously is not between 1137km and 1144km. |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
I am using a dynamic order by statement; ORDER BY CASE @sort WHEN 0 THEN CAST( COALESCE( t2.RANK, 0 ) + COALESCE( t3.RANK, 0 ) AS CHAR( 5 ) ) WHEN 1 THEN C.title WHEN 2 THEN CAST( CEILING( [dbo].[fn_calculateDistance] ( @fromLatitude, @fromLongitude, L.latitude, L.longitude ) ) AS CHAR( 9 ) ) WHEN 3 THEN ( C.locality + ' ' + C.state ) WHEN 4 THEN CAST( C.price AS CHAR( 10 ) ) END ASC The problem is with the numeric values, I have to cast them as a string, but in the results 114km obviously is not between 1137km and 1144km. |
![]() |
| Thread Tools | |
| Display Modes | |
| |