I have this procedure and as it works it works well, but I want to modify it because in the total sum it makes me the sum of all the records and not the ones in the range of a specific date, so I wrote this:
and *****a.fecha >= :fechainicio or a.fecha <= :fechafin ),*****
begin
if (quincena = '1') then
dia='1';
if (quincena = '2') then
dia='16';
ftdfecha =(select cast (:anno||'-'||:mes||'-'||:dia as date) from rdb$database);
fechainicio = ftdfecha;
fechafin = dateadd(15 day to fechainicio);
for select a.codigoproveedor,
(SELECT b.nombreproveedor FROM proveedores b
WHERE a.codigoproveedor = b.codigoproveedor and *****where a.fecha >= :fechainicio or a.fecha <= :fechafin),*****
sum (a.montototal)
FROM produccion a
where (a.fecha >= :fechainicio or a.fecha <= :fechafin)
group by a.codigoproveedor
into :codigoproved,:nombreproved,:producciones
do begin
suspend;
end
end
and this error gives me the Firebird:
Can't format message 13:896 -- message file C:\WINDOWS\firebird.msg not found.
Dynamic SQL Error.
SQL error code = -104.
Invalid expression in the select list (not contained in either an aggregate function or the GROUP BY clause).
Can you tell me how to fix it or write me the code correctly? a thousand thanks