日期:2014-05-17  浏览次数:20521 次

如何数据库表中原有的记录 倒序 显示出来...
ps: 数据库表中字段 为 id 和name 两个字段均可以为空。
   不要告诉我order by  方法。。。因为有的记录id 和name  均为空
   只想实现表中现有记录 倒序显示出来! 
          拜谢!

------解决方案--------------------
好吧,我闭嘴。
------解决方案--------------------
引用:
ps: 数据库表中字段 为 id 和name 两个字段均可以为空。
   不要告诉我order by  方法。。。因为有的记录id 和name  均为空
   只想实现表中现有记录 倒序显示出来! 
          拜谢!


含有Null 数据,还不能用order by 需要显示表中现有记录  还倒序!!!

没理出逻辑思路。 lz给数据还有结果吧。 

------解决方案--------------------
if object_id('[TB]') is not null drop table [TB]
go
create table [TB] (col1 int,col2 nvarchar(4))
insert into [TB]
select null,null union all
select null,null union all
select null,null union all
select null,null union all
select null,null union all
select null,null union all
select 17,'张三' union all
select 15,'李四' union all
select 13,'白华' union all
select 11,'萍乡' union all
select 9,'武汉' union all
select 7,'南昌'

select * from [TB]

SELECT col1,col2 FROM dbo.TB
ORDER BY ISNULL(col1,9999)  --给个值行不?

/*
col1 col2
7 南昌
9 武汉
11 萍乡
13 白华
15 李四
17 张三
NULL NULL
NULL NULL
NULL NULL
NULL NULL
NULL NULL
NULL NULL*/

------解决方案--------------------
楼上的没考虑NULL如下数据
NULL null
NULL null
17 张三
15 李四
NULL null
NULL null
13 白  华
11 萍乡
NULL null
NULL null
9 武汉
7 南昌

LZ真是 好需求