Home Dashboard Directory Help
Search

T-SQL: Provide SCALAR_MIN and SCALAR_MAX by xor88


Status: 

Resolved
 as Won't Fix Help for as Won't Fix


8
0
Sign in
to vote
Type: Suggestion
ID: 767183
Opened: 10/12/2012 7:23:27 AM
Access Restriction: Public
0
Workaround(s)
view

Description

T-SQL has the MIN and MAX aggregate functions. It would be *very* handy to have them for scalars as well.

- They should support all the common data types including uniqueidentifier and bit
- They should take a variable number of arguments
- They should automatically convert types implicitly according to some sensible rules
- They should propagate non-nullness if all arguments are non-null (in case of MAX it is enough if just one argument is guaranteed to be non-null because it will always be greater than NULL)

A scalar UDF is not a useful workaround because they don't inline and are known to be seriously slow.
Details
Sign in to post a comment.
Posted by Microsoft on 4/12/2013 at 2:21 PM
Hello,
After carefully evaluating all of the suggestion items in our pipeline, we are closing items that we will not implement in the near future due to current higher priority items. We will re-evaluate the closed suggestions again in the future based on the product roadmap.

Thanks again for providing the product suggestion and continued support for our product.

--
Umachandar, SQL Programmability Team
Posted by Quassnoi on 10/22/2012 at 10:48 PM
MySQL, PostgreSQL and Oracle call these functions as LEAST and GREATEST
Posted by xor88 on 10/22/2012 at 1:20 PM
Thank you. Please note that the additional requirements that I listed would be quite convenient. All of them have a practical reason (for example propagating nullability is useful to get computed columns to be not-null). All others have concrete reasons as well.

So you might add those requirements to the language request if you agree they are useful.

Thanks.
Posted by Microsoft on 10/22/2012 at 12:20 PM
Hello,
Thanks for your suggestion. We will consider it for a future version of SQL Server. I added it to the list of language requests to consider and we will evaluate feedback/voting on this item & decide.

--
Umachandar, SQL Programmability Team
Posted by xor88 on 10/12/2012 at 7:25 AM
Additional features desired:

- They should evaluate their arguments exactly once, meaning that arguments that are select query expressions are only executed once. This is in contrast to a case-statement currently.
- They should be deterministic and precise if the arguments are
Sign in to post a workaround.