bueno este es el codigo que utilizo y el error dice: error de sintaxis cerca de ff
Código SQL
[-]SELECT DISTINCT a.cod_producto,p.nombre,sum(a.cantidad)/ (date_part('DAY', TIMESTAMP ff- fi) ) as demanda,
(150*sum(a.cantidad)/ (date_part('DAY', TIMESTAMP ff- fi) ))/(p.precio_unid * 0.13) as Q ,
(sum(a.cantidad)/ (date_part('DAY', TIMESTAMP ff-fi) ))/(150*sum(a.cantidad)/ (date_part('DAY', TIMESTAMP ff- fi) ))/(p.precio_unid * 0.13) as N,
(150*sum(a.cantidad)/ (date_part('DAY', TIMESTAMP ff- fi) ))/(p.precio_unid * 0.13)/(sum(a.cantidad)/ (date_part('DAY', TIMESTAMP ff- fi) )) as T,
Stddev(a.cantidad)* sqrt(4) as Desv ,
(Stddev(a.cantidad)* sqrt(4))*1.28 as IS,
sum(a.cantidad)/ (date_part('DAY', TIMESTAMP ff- fi) )*4*((Stddev(a.cantidad)* sqrt(4))*1.28) as R
FROM detalle_venta a, factura_vent fv,producto p
WHERE(( p.cod_producto=a.cod_producto) and (a.cod_fact_vent=fv.cod_fact_vent) and (fv.fecha between :fi and :ff) )
group by a.cod_producto,p.nombre,p.precio_unid