Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sconard
Starting Member
18 Posts |
Posted - 2005-08-24 : 15:57:30
|
| I have a column "title" that is nvarchar 255. I would like ORDER BY results to be standard alpha-numeric. Query of table returns ORDER BY Titles as Lesson 1Lesson 10Lesson 2Instead of...Lesson 1Lesson 2Lesson 10Must I convert the datatype prior to sort?How is this done?Thank you. |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2005-08-24 : 16:43:39
|
Posting the query you used to get those results would help a lot. Is that a single column or two columns of data. Was an ORDER BY used? What columns were ordered?I'm guessing your column "title" has two tokens: "Lesson" separated with a space from "NN" where NN ranges from 1 to 99.Conversion can be done right on the ORDER BYSELECT MyTltle FROM MyTable ORDER BY CAST(RIGHT(MyTitle, 2) AS INT) |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2005-08-24 : 16:49:34
|
| Ideally you would have seperate columns for lessonNumber and lessionTitle.You can sort by one column and display the other. But if you're stuck with thisstructure then you'll need to do something like Sam provided.Be One with the OptimizerTG |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-25 : 02:15:00
|
| Try this alsoSelect title from yourTable order by len(title),titleMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|