日期:2014-05-18  浏览次数:20414 次

求替换一列的代码
无规律的结果集如下:
  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