Re: flagging first row inserted for each "group" of key

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: flagging first row inserted for each "group" of key
Дата
Msg-id 20091217093832.GD10388@a-kretschmer.de
обсуждение исходный текст
Ответ на flagging first row inserted for each "group" of key  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
Ответы Re: flagging first row inserted for each "group" of key  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
Список pgsql-general
In response to Ivan Sergio Borgonovo :
> I've a web application.
>
> I'm logging data related to the landing page and subsequent selected
> hits.
>
> create table track_hit (
>   hitid serial not null,
>   /* pk? I don't mind if serial wrap around
>   pk could be (hitid, tracking_time) */
>   esid varchar(32), -- related to session
>   tracking_time timestamp not null default now(),
>   -- some other stats
>   -- first_hit boolean not null default false, -- ???
> );
>
> I'd like to be sure I just count one "first hit" in a session (same
> esid) in an efficient way that means I'd like to mark them with a

select distinct on (esid) esid, tracking_time from track_hit order by esid, tracking_time;

returns only one record for each esid, ordered by tracking_time. Should
work with 8.x, maybe sice 7.x (I'm not sure)


HTH, Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

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

Предыдущее
От: Ivan Sergio Borgonovo
Дата:
Сообщение: flagging first row inserted for each "group" of key
Следующее
От: Erik Jones
Дата:
Сообщение: Re: Justifying a PG over MySQL approach to a project