create or replace FUNCTION LCR60(pdate DATE)
RETURN number
is
tempdate date;
resultat number;
BEGIN
resultat:=0;
tempdate:=pdate;
SELECT add_months(pdate, -1) INTO tempdate FROM dual;
select sum(f.Prop_60j*f.Prix_TTC) INTO resultat from facture f where f.Mode_Paiement = 'LCR'
										AND to_char(f.date_commande,'MM/YYYY')=to_char(tempdate,'MM/YYYY');
if resultat IS NULL then
  resultat := 0;
end if;
return (resultat);
END;
/