|
Posted by markc600 on 03/14/06 19:09
Here's an example of what you want using a derived table
declare @t table(id int, val1 int,val2 int,val3 int)
insert into @t(id,val1,val2,val3) values(1,100,200,300)
insert into @t(id,val1,val2,val3) values(2,300,400,500)
insert into @t(id,val1,val2,val3) values(3,600,700,800)
select id,max(vals)
from
(
select id,val1
from @t
union all
select id,val2
from @t
union all
select id,val3
from @t
) X(id,vals)
group by id
Navigation:
[Reply to this message]
|