View Single Post
Old 10-14-2005, 14:04   #1 (permalink)
Dylan Parry
Civilians

 
Default SQL Server: Getting numbers in (right) order

Hi folks,

I have a database full of documents and each section within a document
is given an ID like "1.0", "1.1", "1.2" and so on. The datatype is
varchar (I wasn't sure if a better type exists?).

Now this is fine until I get to "1.10" which is then logically between
"1.1" and "1.2" but obviously, in the document it should be after "1.9".
Is there any way I can retrieve data from the database using this sort
of /logical to me, but not to a computer/ manner?

Just in case I am making no sense (which is quite likely); at the moment
I am using something like:

"SELECT id FROM sections ORDER BY id ASC"

Which returns:

1.1, 1.10, 1.11, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9

Whereas I would like to get it in the order:

1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 1.10. 1.11

Is there something magical I can use to achieve this?

Cheers,

--
Dylan Parry
http://webpageworkshop.co.uk -- FREE Web tutorials and references
  Reply With Quote
Trackpads Information
Click to Visit
 
Page generated in 0.61083 seconds with 15 queries