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 |
|
sulman
Starting Member
20 Posts |
Posted - 2007-03-28 : 05:37:49
|
| Hi,I need to query my table so that I return all of the rows from it but the selected row first. e.g.:parameter passed is 3 (id)result would return:id title-- -----3 Title31 Title12 Title24 Title4etc...Could someone please point me in the right direction?Many thanksS |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-28 : 05:41:58
|
| select * from table1order by case when id = @id then 0 else 1 end, idPeter LarssonHelsingborg, Sweden |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-28 : 05:43:33
|
| select id, title from (select 0 as t, id, title from table1 where id = @idunion allselect 1, id, title from table1 where id <> @id) as x order by t, idPeter LarssonHelsingborg, Sweden |
 |
|
|
sulman
Starting Member
20 Posts |
Posted - 2007-03-28 : 05:57:46
|
| Absolutely brilliant.Thanks very much!S |
 |
|
|
rammohan
Posting Yak Master
212 Posts |
Posted - 2007-03-30 : 05:35:34
|
| select * from trail1 where sid = 3 union all select * from trail1 where sid != 3One can never consent to creep,when one feels an impulse to soarRAMMOHAN |
 |
|
|
|
|
|