I have the following query below, the idea is to get the value of the variable @subcategories and put in the IN of the query:
set @subcategorias = replace('10, 11, 29, 30, 31', '''', '');
SELECT
car.NomeCaracteristica,
MAX(catcar.Valor) AS Valor,
catcar.Condicional AS Condicional
FROM
caracteristica car
inner join categoriacaracteristica catcar on car.IdCaracteristica = catcar.IdCaracteristica
WHERE
catcar.IdCategoria IN (@subcategorias) AND
catcar.IdCaracteristica = 19 AND
catcar.Valor is not null
GROUP BY
car.NomeCaracteristica,
catcar.Condicional;
Doing so does not return me the amount of records I need. Should return two instead of one.
I know this because your I put the value in the IN in hand (catcar.IdCategory IN ('10, 11, 29, 30, 31 ')) it works.
Can you tell me what might be happening?