use the builtin typeof() function. This returns the type of the argument: null, text, blob, integer, real as a text string. ``` sqlite> select typeof(a), a from (select 5/0 as a); ┌───────────┬───┐ │ typeof(a) │ a │ ├───────────┼───┤ │ null │ │ └───────────┴───┘ ``` Alternatively, simply see if it is null: ``` sqlite> select case when a is null then 'NaN' else a end from (select 5/0 as a); ┌───────────────────────────────────────────┐ │ case when a is null then 'NaN' else a end │ ├───────────────────────────────────────────┤ │ NaN │ └───────────────────────────────────────────┘ ``` Or even more simply using the ifnull builtin function: ``` sqlite> select ifnull(a,'NaN') from (select 5/0 as a); ┌─────────────────┐ │ ifnull(a,'NaN') │ ├─────────────────┤ │ NaN │ └─────────────────┘ ``` Except, of course, that NULL is a valid value in further arithmetic calculations that will be handled correctly, whereas the text string 'NaN' is not.