一个特殊的排序问题
作者:admin 日期:2008-01-30
					             字段数据如下
0
0
0
1
0
3
0
2
7
5
0
4
6
如何能做到如下排序
1
2
3
4
5
6
7
0
0
0
0
0
0
------------------------------
select id from @t order by case when id=0 then 99999 else id end
-------------------------------
select col from tb
order by
case col
when 0 then 90
else col
end
----------------------------
select id from @t order by case when id=0 then (select max(id)+1 from @t) else id end
------------------------------------------
Select * From A order By IIF(ID = 0, 9999999, ID)
-------------------------------------------
我查了一下,access不能用这个语句,只能用iif
但我的语句总是不成功
select *,iif(cost=0,999,cost) from dbname order by cost
这样写不对吗??
--------------------------------------------
ACCESS這麼寫
Select * From dbname order By IIF(cost= 0, 9999999, cost)
-----------------------------------------------
select * from a order by case when title=2 then -1 else title end
						   
						   
						   
						   0
0
0
1
0
3
0
2
7
5
0
4
6
如何能做到如下排序
1
2
3
4
5
6
7
0
0
0
0
0
0
------------------------------
select id from @t order by case when id=0 then 99999 else id end
-------------------------------
select col from tb
order by
case col
when 0 then 90
else col
end
----------------------------
select id from @t order by case when id=0 then (select max(id)+1 from @t) else id end
------------------------------------------
Select * From A order By IIF(ID = 0, 9999999, ID)
-------------------------------------------
我查了一下,access不能用这个语句,只能用iif
但我的语句总是不成功
select *,iif(cost=0,999,cost) from dbname order by cost
这样写不对吗??
--------------------------------------------
ACCESS這麼寫
Select * From dbname order By IIF(cost= 0, 9999999, cost)
-----------------------------------------------
select * from a order by case when title=2 then -1 else title end
评论: 0 | 引用: 0 | 查看次数: 2308
			
发表评论
      
      你没有权限发表留言!
 订阅
上一篇
下一篇
 
 
					              
							  
文章来自: 
Tags: 




