What does it mean "ascending order based on the numeric value of the string"?
The order of the rows in the original table?
Alphabetical case sensitive order of String column?
One way to look at it is as follows:'A' is equal to the number x41.'B' is equal to the number x42. x42 is bigger than x41 thus 'B' comes after 'A'.'AB' is equal to x4142. As a number, that's bigger that x41 or x42. Thus 'AB' comes after 'A' and 'B' in the sort order.This is the principle you need to apply.
Even though this may look like a simple challenge, let's try this simple performance test. I'm going to use Stefan's approach of using a single row of data which, in challenge 41, really intreagued me.
Query:
if object_id('tc46') is not null drop table tc46 go create table tc46 (String varchar(max)) go insert into tc46 select replicate(convert(varchar(max),'a'),1000000)+'b' go select *,LEN(String) l from tc46
The Results-column should naturally show just 'b'.
Here are my statistics:
(1 row(s) affected) Table 'tc46'. Scan count 1, logical reads 1, physical reads 0, read-ahead reads 0, lob logical reads 1238, lob physical reads 0, lob read-ahead reads 428. Table 'Worktable'. Scan count 0, logical reads 7, physical reads 0, read-ahead reads 0, lob logical reads 888849, lob physical reads 0, lob read-ahead reads 122. SQL Server Execution Times: CPU time = 3109 ms, elapsed time = 3265 ms.
OK, with a slight tweak I got this down to:(1 row(s) affected)Table 'tc46'. Scan count 1, logical reads 1, physical reads 0, read-ahead reads 0, lob logical reads 1240, lob physical reads 0, lob read-ahead reads 489.Table 'Worktable'. Scan count 0, logical reads 13, physical reads 0, read-ahead reads 0, lob logical reads 117582, lob physical reads 0, lob read-ahead reads 366. SQL Server Execution Times: CPU time = 453 ms, elapsed time = 562 ms.
Should it be ordered on the String or on the Result ?
I think the expected results in the challenge description shows clearly on which column to order: the String.
@dishdy
The Results-column should naturally show just 'ab'.
Are you sure?
Can be in String chars with ascii codes <32 and >127 ?
@Leszek Gniadkowski
The Results-column should naturally show just 'ab'.[/quote] Are you sure?
Ooops. Fixed it.Actually I was checking to see if everyone is awake .-)
ascci code>=32 and ascii code<=255
Managed Windows Shared Hosting by OrcsWeb