If Igor "must have a number" for the "max", even when there are no rows, then I'm certain that the coalesce() function is exactly what he needs to use. coalesce(max(id),0)) will give the maximum "id" value of the result set or 0 if there are no results in the result set (NULL).
On Sun, Nov 10, 2013 at 10:44 AM, Simon Slavin <slav...@bigfraud.org> wrote: > > On 10 Nov 2013, at 4:26pm, Igor Korot <ikoro...@gmail.com> wrote: > > > I'm updating the table when the program exit. > > There is not need to update the table. In fact there's no need to store > the rank values at all. > > > Now, I would expect for the max() function in this case to be > > evaluated to 0 and not NULL. > > This is plain mathematics: max value of nothing is nothing which > > mathematically 0. > > No. Max of nothing is nothing. And the way you express 'nothing' in SQL > is NULL. NULL is not 0 or 0.0. NULL is not the empty string "". NULL is > not the BLOB x''. NULL means 'value missing'. > > As another contributor to the thread noted, suppose you have a list of any > number of values. You remove them one by one. At each stage, the maximum > of the remaining list can only remain the same or get smaller. Why should > removing the last number somehow /increase/ the maximum of a list ? Now > suppose your list is -18, -41, -23 and you remove them in any order. > > Simon. > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- This is clearly another case of too many mad scientists, and not enough hunchbacks. Maranatha! <>< John McKown _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users