What to do if the query result is NULL, but it should be 0.
The following problem arose, in the case of the absence of data in the table, the result of the maximum value query in the field will output a value of null, of course, you can handle the result in the program, but it is significantly easier to assign this functionality to a script.