Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 1DCAA632D4D for ; Wed, 7 Jul 2010 18:20:24 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 55357-01 for ; Wed, 7 Jul 2010 21:20:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mail.postgresql.org (Postfix) with SMTP id 073FB632D2A for ; Wed, 7 Jul 2010 18:20:15 -0300 (ADT) Received: (qmail invoked by alias); 07 Jul 2010 21:20:14 -0000 Received: from mue-88-130-46-051.dsl.tropolys.de (EHLO [192.168.0.113]) [88.130.46.51] by mail.gmx.net (mp064) with SMTP; 07 Jul 2010 23:20:14 +0200 X-Authenticated: #14269776 X-Provags-ID: V01U2FsdGVkX1+zJLYVRc+zYAfFznF+NbR0ATKfZ2JAwi0IRY7tOP VaRBr5qyNWlZ5p Message-ID: <4C34EF8F.5010202@gmx.net> Date: Wed, 07 Jul 2010 23:20:15 +0200 From: Andreas User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.4) Gecko/20100608 Thunderbird/3.1 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: How to find events within a timespan to each other? Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.011 tagged_above=-5 required=5 tests=BAYES_20=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201007/36 X-Sequence-Number: 34349 Hi, is there a way to find events in a log that happen within a certain timespan to each other? Log is like this event_id integer not null default 0 primary key event_type_id integer not null default user_id integer not null default 0 event_ts timestamp(0) I need every event of a type that happened more often than one time within 5 minutes of another one of the same user. 17 3 1 ... 12:00 18 2 .... 19 3 1 ... 13:03 20 3 2 ... 13:03 21 3 1 ... 13:04 22 2 ..... 23 3 1 ... 13:05 24 2 1 ... 13:06 E.g. the checked event_typ_id may be 3 then the result should be line 19, 21, 23 regards Andreas :)