Re: SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps

Поиск
Список
Период
Сортировка
От Jasen Betts
Тема Re: SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps
Дата
Msg-id gqa9oi$kv1$4@reversiblemaps.ath.cx
обсуждение исходный текст
Ответ на SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps  (Srikanth <rssrik@yahoo.co.in>)
Список pgsql-sql
On 2009-03-17, Srikanth <rssrik@yahoo.co.in> wrote:

> Dear all,
>
> I have a table that records User Login Sessions with two timestamp fields. =
> Basically Start of Session and End of a Session (start_ts and end_ts). Each=
>  row in the table identifies a session which a customer has used.=A0=20
>
>
> I have to find out how many User Sessions that were present in any given "1=
>  HOUR TIME PERIOD".=A0 A single User Session can span across many days.

select count(*) from session WHERE start_ts < TIME + '1 hour'::intervalAND   end_ts >= TIME;
(replace both ocurrences of TIME with the time the interval starts)


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

Предыдущее
От: Jasen Betts
Дата:
Сообщение: Re: cast bool/int
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Alter Table/Indexing