这帖中已经回复http://community.csdn.net/Expert/topic/3381/3381231.xml?temp=.9878961
解决方案 »
- 用存储过程实现
- 关于数据查询的问题。。急
- 这个动态SQL语句要怎么执行呢?有参数的
- 悲剧了,如下
- 无法打开数据库 'myshoppos'(版本 0)。请将该数据库升级为最新版本。
- 急问:从MS SQL Server 6.5中导出的的数据库文件在MS SQL Server 2000中如何打开?
- 如何设置ADO的连接字符串使用ado写的程序可以访问不在本地的sql server?
- 500分急救:Log Explorer 4.2.1 版可以还原sql2005数据吗 哪位兄弟有啊,可下载链接也行
- ******不能连接上远程数据库**********
- 求获取标识的insert的SQL语句
- 一个简单问题:A电脑怎么访问到B电脑上的ODBC数据源
- 存储过程访问另一个库有密码怎么办?在线!!!
2.排序的话,单独的order by age,则null的在前面,非null在后面
如果你想叫null的在后面的话,order by中使用case when结果控制一下就可以了。
select * from 表
order by case when age is null then 1 else 0 end,age
create table tb(id int identity(1,1),age int)
insert tb values ('1')
insert tb values ('5')
insert tb values ('2')
insert tb values (null)
insert tb values (null)select * from tb
order by case when age is null then 1 else 0 end,age
drop table tb--运行结果:id age
----------- -----------
1 1
3 2
2 5
4 NULL
5 NULL(所影响的行数为 5 行)