Hi,
In my workflow, I use an SQL query to retrieve the last chrono number recorded in the database for specific categories.
My initial SQL query is :
SELECT COALESCE(MAX(num), 0) AS last_num
FROM table
WHERE YEAR(date_insert) = ? AND cat in (?) ;
My variables are
? = 2024
? = 'cat1', 'cat2'
In the end, this is what my SQL query looks like:
SELECT COALESCE(MAX(num), 0) AS last_num
FROM table
WHERE YEAR(date_insert) = 2024 AND cat in ('cat1', 'cat2') ;
I do get a return, but it doesn't give me the last number; instead, it gives me "0".
For your information, the last number in my database is "5".
I think the problem comes from the 2nd parameter "cat in ('cat1', 'cat2')".