Sorting

  • Thread starter Thread starter Adrian
  • Start date Start date
A

Adrian

When I sort a number I get a lexicographical sort
1
11
112
1
12
How can I code a sort that will produce
a proper numerical order?

Adrian.
 
Hi Adrian,

Why don't you set column's DataType to a numeric one (I guess you have it
set to string now).
 
Why don't you set column's DataType to a numeric one (I guess you have it
set to string now).

Miha,

Yes, but more generally I was looking for an expression like
VALUE([column name]) in a SQL command line.

Adrian.
 
Hi,

So you want to do sorting on database. What database?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Adrian said:
Why don't you set column's DataType to a numeric one (I guess you have it
set to string now).

Miha,

Yes, but more generally I was looking for an expression like
VALUE([column name]) in a SQL command line.

Adrian.
 
Adrian said:
When I sort a number

Youre sorting text, not numbers. It matters little to the computer that
the text is composed entirely of numeric characters - it's text, not a
number

How can I code a sort that will produce
a proper numerical order?

Use numbers, not text
 
You might use cast or convert function and sort on the result, something
like ... order by case(comecolumn as int)
 
Back
Top