On Jan 27, 2012, at 8:43 PM, K Peters wrote:

> Why would the second statement still return null if the first statements
> returns 'null'?
> 
> 
> select typeof(max(id)) from categories  -- returns 'null'
> select case max(id) when null then 1 end as NextID from categories

As mentioned, null is, hmmm, special [1].

Try:

select case when max(id) is null then 1 end ...

Or:

select coalesce( max( id ), 1 )


[1] http://en.wikipedia.org/wiki/Null_(SQL)

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to