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
 General SQL Server Forums
 New to SQL Server Programming
 Relational Operator

Author  Topic 

WoodHouse
Posting Yak Master

211 Posts

Posted - 2010-05-06 : 08:03:34

Help on this


How to find out the biggest or smallest of two numbers without using logical and Relational Operator ?

Thanks
wood

gpl
Posting Yak Master

195 Posts

Posted - 2010-05-06 : 08:16:03
That pretty much rules out everything!
What are you trying to do and why the restriction ?
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-05-06 : 08:33:08
Probably some kind of homework or test or something.

- Lumbago
If the facts don't fit the theory, change the facts. Albert Einstein
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-05-06 : 08:50:28
What do you mean?
Do you have examples of input/output and what kind of solution you don't want to use?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2010-05-06 : 09:22:25
Look at the two numbers and then pick the biggest or smallest.






CODO ERGO SUM
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-05-06 : 09:58:14
SELECT MIN(Col), MAX(Col) FROM myTable99

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

apodemus
Starting Member

30 Posts

Posted - 2010-05-06 : 10:01:29
I agree MVJ :)

apodemus
Go to Top of Page

DBA in the making
Aged Yak Warrior

638 Posts

Posted - 2010-05-06 : 10:22:03
quote:
Originally posted by WoodHouse
How to find out the biggest or smallest of two numbers without using logical and Relational Operator ?


Even though it sounds like homework...
DECLARE @Num1 INT SET @Num1 = 5
DECLARE @Num2 INT SET @Num2 = 10

DECLARE @tbl TABLE (Num INT)

INSERT INTO @tbl
SELECT @Num1 UNION ALL
SELECT @Num2

SELECT MIN(Num) AS Smallest, MAX(Num) AS Largest
FROM @tmp


------------------------------------------------------------------------------------
Any and all code contained within this post comes with a 100% money back guarantee.
Go to Top of Page
   

- Advertisement -