Good point. Just small correction. It was possible to write queries this (wrong) way before Set EngineBehavior was invented.
>Just to add, Ulises did not include every non-aggregate field (left out Productos.descrip) in the Group By clause that was in the Select clause. Although Set EngineBehavior allows you to write SQL this way it's bad practice and the values in the Productos.descrip column are essentially meaningless.
>
>
>>You cannot use aggregate function in the WHERE because they are not calculated yet. You should move it to HAVING clause
>>
>>>
SELECT Invent.codigo, Productos.descrip, SUM(Invent.saldoenivel);
>>> .....
>>> GROUP BY Invent.codigo;
--sb--