Subject Re: [firebird-support] How to add previous column value to current value?
Author setysvar
>I need something like this
>
>Name Date Days betwen Previous date
>----------------------------------------------------------------------
>Name1 date1 0
>Name2 date2 date2-date1
>Name3 date3 date3-date2

I agree with Thomas in that EXECUTE BLOCK is probably the best solution,
but an (inferior) alternative is:

SELECT T1.Name, T1.MyDate, coalesce(T1.MyDate - (SELECT MAX(T2.MyDate)
FROM MyTable T2 WHERE T1.MyDate > T2.MyDate), 0)
FROM MyTable T1

The main reason for me calling it inferior, is that it will be slow for
large tables without additional selective WHERE criteria for T2.

HTH,
Set