Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
rkumar28
Starting Member
49 Posts |
Posted - 2006-06-16 : 17:40:59
|
| Hi,I have a table that has quite a few coulmns. I am trying to grab the bigger value from the two columns (ID1 and ID2).Table1:ID1 ID212 10 ---> In this I should be able to grab 12 from ID1 field.50 100 ---> In this I should be able to grab 100 from ID2 fieldHow to grab the bigger values among the two fields.e.g.: In first row above, since 12 is bigger than 10 then I want to grab 12 from ID1 field. In second row the 100 is bigger than 50 then I want to grab 100 from ID2 field. Below is the output that I am trying to generate the output somehting like:OutPut 12100Raj |
|
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2006-06-16 : 17:45:15
|
| create table #tmp ( c1 int, c2 int)insert into #tmp values (12,10)insert into #tmp values (50,100)select case when c1 > c2 then c1 else c2 END as MaxValuefrom #tmp"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
 |
|
|
|
|
|