June 1, 2017 at 11:26 am
SQLArnold - Thursday, June 1, 2017 9:03 AMdmartin 38210 , I am a huge fan of Itzik. This is a great option, thanks!
If you like that solution, you might want to read about how it actually works. Please see the following.
http://www.sqlservercentral.com/articles/Tally+Table/72993/
--Jeff Moden
Change is inevitable... Change for the better is not.
November 15, 2017 at 12:30 pm
By taking the best of all the responses, seems like this works for any datatype and is easy enough to do without typing the same value/variable over and over:
select [Greatest] = max(t.x)
, [Least] = min(t.x)
from (values (123), (23), (null), (77)) as t(x)
You can use variables, scalar function calls etc.
Viewing 2 posts - 16 through 16 (of 16 total)
You must be logged in to reply to this topic. Login to reply