Did you know that a Code field is sorted different depending of you are using Native or SQL?
SQL will sort the Code field as a Varchar – which means it will sort the Code field as text!
In the following sorting example you can see the sorting Native vs. SQL
Native SQL 1 1 2 10 3 2 10 3 A A AA B B C C AA
So what to do if you are using SQL and still want a code field to be sorted in the same way as in Native? Use temporary tables!
Temporary tables acts in the same way as a Native table