I'm trying to get the first free code between two values and I do not know what I'm doing wrong that always gives me 2
when there are numbers above 2
.
this is the code I'm using:
SELECT MIN('Ean')+1 as prox_ean_libre FROM 'CodigosEan' WHERE 'Ean' BETWEEN '843447200001' AND '843447299999' AND 'empresa' = '199'
In the database I have a record with the code 843447200003 but it still gives me 2
instead of 4
.
What am I doing wrong?