my query works fine on any table
SELECT MAX(id_nombre) +1 AS max_id_nombre from {{table_bon_de_commande_client.data}}
NOT in one case: if the max value of my column is 1, it is considered as a text, and returns the value 11 for max(1)+1
Or for 0, if there is no value in my table, the result of this query is "undefined".
the exact same query works fine for all other values, if i add rows to my table. As you can see on the screenshots.
I have deleted and recreated my table, created new google sheet file and new queries, setting the good format for all the column.
Then, when i put decimals to my 1, the cell contains 1.0
the query returns max(1.0)+1 = 1.01
the problem is not the value 1,
the problem occurs when there is only one row of data in my table.
And i want to allow the creation of a new table from 0 row........
For the 1, I'm only able to reproduce this issue when 1 is a string. Even though your ID nombre column is a Number column, maybe the underlying data is a string? Changing the column type in the table will not impact anywhere that you're referencing table1.data
For 0, it looks like if there is a number 0 in your data, it should work. But if you're passing in an empty array for the table data, the expected result is undefined: