Re: Need to subtract values between previous and current row

Поиск
Список
Период
Сортировка
От Richard Broersma Jr
Тема Re: Need to subtract values between previous and current row
Дата
Msg-id 519101.72709.qm@web31802.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на Re: Need to subtract values between previous and current row  ("Partha Guha Roy" <partha.guha.roy@gmail.com>)
Ответы Re: Need to subtract values between previous and current row  (Ragnar <gnari@hive.is>)
Список pgsql-sql
> CID        ATIME          STATE
> 101        12/10/2006     1
> 101        12/12/2006     2
> 101        12/14/2006     1
> 101        12/17/2006     2
> 102        12/14/2006     1
> 102        12/16/2006     2
> 102        12/18/2006     3

select A.cid, (A.atime - max(B.atime)) duration, A.state
from table A join table B
on (A.atime > B.atime and A.cid = B.cid)
group by A.atime, A.cid, A.state;



В списке pgsql-sql по дате отправления:

Предыдущее
От: Ragnar
Дата:
Сообщение: Re: Need to subtract values between previous and current row
Следующее
От: Ragnar
Дата:
Сообщение: Re: Need to subtract values between previous and current row