Subject Re: [firebird-support] Firebird SQL query - Average days between dates
Author Radu Sky
bill_zwirs wrote:
> Firebird 1.5.3
> Delphi 5 Pro
>
> I have a table in a Firebird database (Sales table) that includes a
> CustID and SaleDate field. Is it possible to query this table (with a
> select statement)to get the Average days between saledates for a
> particular customer.
>
> thanks in advance
>
> Bill
>


SELECT (MAX(SaleDate)-MIN(SaleDate))/COUNT(SaleDate) FROM sales
WHERE CustID=:CustID AND (SaleDate BETWEEN :From_date AND :Till_date)


HTH
Radu