取一行中最大值

 群里有朋友提出,要取一行中最大的值。

搜到邹老大的解决办法:

create table #temp(a int,b int,c int,d int)
insert into #temp values(1,4,11,3)
insert into #temp values(2,5,11,32)

select (

    select max(col) from (

        select col=a union all select col=b union all select col=c union all select col=d

    ) a

) from #temp

结果:

11

32

你可能感兴趣的:(c,table,insert)