Ahora que lo veo nuevamente, me parece que me ha faltado un detalle importante.
Código SQL
[-]Select
Max(Codclient) as Codclient,
Max(Fecha) as Fecha,
Producto,
Sum(Unidades) as Unidades,
Max(Precio) as Precio,
Sum(Subtotal) as Subtotal,
Avg(Precio) as PMedio,
Min(Precio) as MPrecio,
(select first 1 X.precio from LineasVentas X
where X.Codclient = :C And
X.Fecha between :F1 and :F2 And
X.Producto = Producto
order by X.fecha desc) as UltimoP
from LineasVentas
Where Codclient = :C And Fecha between :F1 and :F2
Group By Producto
Having Sum(Unidades) <> 0
Order by Producto
Saludos