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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 min

Author  Topic 

eddie
Starting Member

45 Posts

Posted - 2002-04-25 : 10:02:27
I know I can use the min function to grab the minumum value a column but is there a fuction to grab the minimum value from two different columns?

Ex. I have two values and I want to get the min one..

This doesn't work but something like this:
Declare @num1 int
Declare @num2 int
Set @num1=1
Set @num2=3

Select min(@num1,@num2) I would want to return 1.

Thanks,
Eddie

Onamuji
Aged Yak Warrior

504 Posts

Posted - 2002-04-25 : 10:09:08

declare @x int
declare @y int

set @x = 1
set @y = 3

select min(val)
from (select @x val union select @y val) as vals


Go to Top of Page
   

- Advertisement -