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 |
|
sql777
Constraint Violating Yak Guru
314 Posts |
Posted - 2006-10-25 : 12:07:21
|
| Greetings,My table has word definitions in them, and I am grouping them by letters (A,B,C) and I want to order the words alphabetically also.LetterID represents A, B, C with numbers: 1, 2, 3. So A=1, B=2, etc.Table1:WordID Word LetterID SortOrder23 Car 3 024 Bat 2 025 Bee 2 0So I want to update the 'SortOrder' field so I can do a query to grab all the definitions that begin with 'B' like:SELECT * FROM Table1 WHERE LetterID = 2 ORDER BY SortOrder |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2006-10-25 : 12:18:08
|
| update tset SortOrder = (select count(*) from table1 where t.letterID = letterID and t.word < word)from table1 tJay White |
 |
|
|
sql777
Constraint Violating Yak Guru
314 Posts |
Posted - 2006-10-25 : 12:19:42
|
| thanks page!X002548: Yeah I can do that also, but the table actually has other rows in it and I don't really want to add an index on the 'word' field. |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-10-25 : 13:49:15
|
quote: Originally posted by sql777 thanks page!X002548: Yeah I can do that also, but the table actually has other rows in it and I don't really want to add an index on the 'word' field.
You don't need an index on a column to order by it.CODO ERGO SUM |
 |
|
|
|
|
|
|
|