27,579
社区成员
发帖
与我相关
我的任务
分享
--测试数据
if not object_id(N'Tempdb..#T') is null
drop table #T
Go
Create table #T([id] int,[名称] nvarchar(24),[编号] int)
Insert #T
select 23,N'办公耗材',0 union all
select 24,N'办公家具',0 union all
select 25,N'办公设备',0 union all
select 26,N'后勤耗材',0 union all
select 27,N'后勤设备',0 union all
select 28,N'生产辅料',0 union all
select 29,N'生产设备',0 union all
select 30,N'其它',0 union all
select 31,N'打印耗材',23 union all
select 32,N'数码类',23 union all
select 33,N'文具类',23 union all
select 34,N'印刷品',23 union all
select 35,N'其它',23 union all
select 36,N'办公家具',24 union all
select 37,N'其它',24 union all
select 38,N'打印设备',25 union all
select 39,N'电器类',25 union all
select 40,N'数码类',25 union all
select 41,N'其它',25 union all
select 42,N'电器类',26 union all
select 43,N'劳保用品',26 union all
select 44,N'配件类',26 union all
select 45,N'其它',26 union all
select 46,N'日用品',26 union all
select 47,N'石化制品',26 union all
select 48,N'五金工具',26 union all
select 49,N'医药用品',26 union all
select 50,N'照明设备',26 union all
select 51,N'电器类',27 union all
select 52,N'配件类',27 union all
select 53,N'其它',27 union all
select 54,N'数码类',27 union all
select 55,N'五金工具',27 union all
select 56,N'仪器类',27 union all
select 57,N'运输工具',27 union all
select 58,N'耗材',28 union all
select 59,N'电器类',29 union all
select 60,N'机械类',29 union all
select 61,N'配件类',29 union all
select 62,N'其它',29 union all
select 63,N'数码类',29 union all
select 64,N'五金工具',29 union all
select 65,N'仪器类',29 union all
select 66,N'运输工具',29 union all
select 67,N'机械类',30 union all
select 68,N'其它',30 union all
select 69,N'日用品',30 union all
select 70,N'数码类',30 union all
select 71,N'文体用品',30 union all
select 72,N'五金工具',30 union all
select 73,N'医药用品',30 union all
select 74,N'办公家具',26 union all
select 75,N'耗材',26 union all
select 76,N'照明工具',26 union all
select 77,N'文具类',26 union all
select 78,N'运输工具',26 union all
select 79,N'机械类',27 union all
select 80,N'办公家具',30 union all
select 81,N'配件类',28 union all
select 82,N'其它',28 union all
select 83,N'食品类',30
Go
--测试数据结束
SELECT a.id ,
a.名称 ,
a.编号 ,
b.名称 AS 组别
FROM #T a
JOIN #T b ON a.编号 = b.id