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 |
|
aoriju
Posting Yak Master
156 Posts |
Posted - 2011-09-27 : 03:33:16
|
| DECLARE @str VARCHAR(100);SET @str ='SR'; with tbl as( select *, row_no = row_number() over (order by [RequestId]) from workflow_Request )select *from tblwhere @str <> 'SR'or (@str = 'SR' and row_no <= 10) I want to use RequestId as Order By when it is not Nullelse Order By as MasterId |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-09-27 : 03:36:42
|
[code]ORDER BY isnull(RequestId, MasterId)[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
aoriju
Posting Yak Master
156 Posts |
Posted - 2011-09-27 : 04:27:49
|
| I have some other conditions..so looking for Case statement |
 |
|
|
Ranjit.ileni
Posting Yak Master
183 Posts |
Posted - 2011-09-27 : 04:33:47
|
some thing like this..ORDER BY CASE WHEN col1!='Transfer' THEN col2 END ,CASE WHEN col1='Transfer' THEN col3 END DESC --Ranjit |
 |
|
|
|
|
|