当前位置: 代码迷 >> Sql Server >> 求替换一列的代码解决思路
  详细解决方案

求替换一列的代码解决思路

热度:65   发布时间:2016-04-27 16:41:19.0
求替换一列的代码
无规律的结果集如下:
  A               B
001 25
003 02
008 22
108 09
207 07
210 32
214 16
...             ...

有如下语句:
select   id,sss,num,time....from   table
其中sss就是上面结果集中的B那一列。
如何把sss换成A那一列呢?
select   id,sss,num,time....from   table


------解决方案--------------------
select t.id,m.A,t.num,t.time... from
(select id,sss,num,time....from table) t,
(select * from tb) m
where t.sss = m.b
------解决方案--------------------
select id,(select a from tb where b=cc.sss),num,time....from table cc
  相关解决方案