日期:2014-05-18 浏览次数:20409 次
--> 测试数据:[TB] if object_id('[TB]') is not null drop table [TB] go create table [TB]([id] int,[bumen] varchar(4),[name] varchar(4)) insert [TB] select 1,'财务','李一' union all select 2,'行政','张二' --------------开始查询-------------------------- select isnull(col,''),name from ( select null as col,name,id from [TB] union all select cast (id as varchar) col,bumen,id from [TB] )t order by id,col ----------------结果---------------------------- /* ------------------------------ ---- 李一 1 财务 张二 2 行政 */