ISNAN

isnan(expr)

Description

The ISNAN function is used to determine whether the given expression expr is NaN (Not a Number). When the value of expr is NaN, the function returns true; otherwise, it returns false. This function is mainly used to handle numerical anomalies and ensure data accuracy.

Parameter Description

  • expr: The expression to be evaluated, of type double.

Return Type

The return result is of type boolean, i.e., true or false.

Usage Example

  1. Determine whether the string 'NaN' is NaN after being converted to double:
SELECT isnan(cast('NaN' as double)); -- The result is true
  1. Use the ISNAN function in a query to filter NaN values:
    SELECT * FROM orders WHERE isnan(total_amount);

In this example, if there are NaN values in the total_amount column, the ISNAN function will return true, thus helping to filter out these records.

  1. Determine whether a calculation result is NaN and perform conditional filtering based on the result:
    SELECT * FROM products WHERE isnan(discount_price);