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 |
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-03-13 : 02:29:37
|
| I have a query to order by ascending to apply in checkbox.Can I order by start with Hello?NameHelloAmyBrianCaty.... |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-03-13 : 02:35:45
|
[code]order by case when Name = 'Hello' then 1 else 2 end, Name[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-03-13 : 02:49:00
|
| What does 1 and 2 meant? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-03-13 : 02:53:35
|
just numbers. when name is HELLO, the 1st ORDER BY parameter will have 1 and hence will be sorted first before the rest (others will be 2) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-03-13 : 02:55:09
|
if you still don't get that, see thisselect NAME, sort = case when Name = 'Hello' then 1 else 2 endfrom yourtableORDER BY sort, NAME KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-03-13 : 03:13:21
|
| select 'ALL' as Name, NULL as label union select (label + ' (' + Name + ')') as label, Name from tablename order by case when Name = 'All' then 1 else 2 end, Nameim getting error invalid column name 'Name' |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-03-13 : 03:44:26
|
[code]select Name, labelfrom( select 'ALL' as Name, NULL as label union select (label + ' (' + Name + ')') as label, Name from tablename) aorder by case when Name = 'All' then 1 else 2 end, Name[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|