| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-06-08 : 08:03:56
|
Eduardo writes "Hello, I Want to Know how I must Writte a query to Order This Table:Id After_of_Id =================1 1 2 4 3 9 4 7 5 8 6 9 7 4 8 2 9 8 10 1 The Result must to be like ThisId=== 110 2 8 5 9 3 6 7 4Thanks a Lot.Eduardo" |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-06-08 : 12:16:27
|
| SELECT IdFROM Table1ORDER BY After_of_Id, IdTara |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-06-08 : 12:22:31
|
| That's GOT to be a homework question....Brett8-) |
 |
|
|
drymchaser
Aged Yak Warrior
552 Posts |
Posted - 2004-06-08 : 12:31:41
|
| [confused]I did not see any logical solution to sort the table the way Eduardo suggests.[/confused] |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-06-08 : 12:36:21
|
quote: Originally posted by drymchaser [confused]I did not see any logical solution to sort the table the way Eduardo suggests.[/confused]
True...but I bet the requested result set is mixed up....Brett8-) |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-06-08 : 12:38:04
|
| The data in After_of_Id specifies the order. Then when there are duplicates of After_of_Id, order by Id.Tara |
 |
|
|
drymchaser
Aged Yak Warrior
552 Posts |
Posted - 2004-06-08 : 12:50:37
|
quote: Originally posted by X002548
quote: Originally posted by drymchaser [confused]I did not see any logical solution to sort the table the way Eduardo suggests.[/confused]
True...but I bet the requested result set is mixed up....Brett8-)
Really messed up... |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-06-08 : 13:02:36
|
quote: Originally posted by tduggan The data in After_of_Id specifies the order. Then when there are duplicates of After_of_Id, order by Id.Tara
Look closer...Brett8-) |
 |
|
|
joldham
Wiseass Yak Posting Master
300 Posts |
Posted - 2004-06-08 : 13:04:16
|
| Tara,Your result set will return ID 11082745936Which is not the result set he wants.He basically wants to sort by the After_of_ID column for first record and then sort by the After_of_id of the ids returned from the first sort order. I don't have time to look at it right now, but the only wa I can see to return this would be to generate a temp table of some kind. Unless I missed something obvious.Jeremy W. Oldham |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-06-08 : 13:05:40
|
quote: Originally posted by X002548 Look closer...
Got to stop doing shots in the morning. Tara |
 |
|
|
joldham
Wiseass Yak Posting Master
300 Posts |
Posted - 2004-06-08 : 13:26:33
|
| There also appears to be a problem with his result set. He has id 2 in third place when the After_of_id column says it should not appear until after id 4 making id 2 the last record in the result set instead of the 3rd record. Or should id 2 have an after_of_id of 10?Eduardo can you help us out here to make sure we are following your logic? Do you want the result in a single result set or is a stored procedure?Jeremy W. Oldham |
 |
|
|
|