日期:2014-05-17 浏览次数:20464 次
select case when rand() between 0 and 0.3 then b when rand() between 0.3 and 0.6 then e else g end from 你的表 where a=2;
------解决方案--------------------
这个是取随机column
create table #a(a int , b varchar(10),c varchar(10),d varchar(10),e varchar(10),f varchar(10),g varchar(10))
insert into #a
select 1 ,'fd' ,'f34' ,'54a-' ,'dft4' ,'gh5_g' ,'dfttg' union all
select 2, 'tewrt', 't5e', 'ret4', 'hrt' ,'gh+', 'dfs3' union all
select 3, 'dtr', 'fsd', 'erw3', 'fs' ,'+_dsf' ,'sdg'
--select * from #a
declare @t int
select @t=cast(RAND()*3 as int)
select (case @t when 0 then b when 1 then e when 2 then g end )x from #a where a=2