Which T-SQL function is used to return the lowest value from two columns while ignoring NULL values?

Prepare for the Fabric Certification Test. Enhance your knowledge using flashcards and multiple choice questions. Each question provides hints and detailed explanations. Be well-prepared for your certification exam!

The T-SQL function that effectively returns the lowest value from two columns while ignoring NULL values is LEAST. When using LEAST, if one or both of the values are NULL, they are disregarded in determining the lowest value. Instead, LEAST evaluates the non-NULL values to find the minimum among them.

For example, if you have two columns – one with a numeric value and the other NULL – LEAST will return the non-NULL numeric value. If both columns contain NULLs, LEAST will yield a NULL result rather than an error. This behavior is specifically designed to accommodate scenarios in which NULL values may appear in the data, allowing users to focus on finding the minimum of meaningful data entries.

In contrast, COALESCE returns the first non-NULL value from a list of arguments, which can be useful but does not specifically serve the purpose of finding the lowest value between two columns. MIN is an aggregate function used to find the lowest value in a set of values, but it does not compare two separate columns directly without aggregating data. IIF is a conditional function that returns one of two values based on a condition, which may not directly compute the minimum value between columns as required in this scenario.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy