SQLite Strangeness

I had a need to get the max value of a field from a table, a table that MIGHT have no records

First I tried this

let SQL="SELECT max(rowid) as maxRow FROM dataStore"

which returned ONE RECORD with maxRow = NULL if the table was empty,

so I tried this

let SQL="SELECT if(null,max(rowid),0) as maxRow FROM dataStore"

I expected a 0 if the table was empty, but instead got ZERO records

anyone have an idea how to get One Record with MaxRow=0 if the table is empty?

Use the coalesce function

 let SQL=SELECT ifnull(max(rowid),0) as maxRow FROM dataStore"