How can I make a sql query where I select the maximum value of the folio column plus one, taking into account that the table may be empty the first time it is used, I have the following query but I think it is missing more.
the query to get the maximum value + one is:
SELECT MAX(FOLIO)+1 AS FOLIOSIGUIENTE FROM LOTE_ENVIO
and the query I have is with a case so that when the value is 0 then I change it to 1
SELECT
CASE MAX(FOLIO)
WHEN '0' THEN '1'
ELSE '1'
END
FROM LOTE_ENVIO
can be done in a single instruction?