pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas <maps.on@gmx.net>
To: pgsql-sql@postgresql.org
Subject: Re: need help with some aggregation magic
Date: Thu, 09 Jun 2011 18:13:36 +0200
Message-ID: <4DF0F130.5070105@gmx.net> (raw)
In-Reply-To: <F17937FAF7064F8DB2173ADD36DC2115@marktestcr.marktest.pt>
References: <4DF0CDFC.4070802@gmx.net>
	<F17937FAF7064F8DB2173ADD36DC2115@marktestcr.marktest.pt>

The log holds events and the ts is just the timestamp when the event 
occured.
The events are kind of "opened form xxx with id xxx", "clicked button 
xxx", "switched to record xxx", ... They were primarily meant for 
helping me to find possible bugs when the user complains that it doesn't 
work but can't say what he did or where the error came up.

The projects don't overlap per user.

So I have time intervals with events for a project and I need to find 
the first and last event for every interval to add up the time 
difference and calculate the sum per day.



Am 09.06.2011 16:16, schrieb Oliveiros d'Azevedo Cristina:
> The ts means the time the user started on a project ?
> Or the time he finished?
> Or can mean both? If so, how do you can tell one from the other? 
> Different event_type s ?
> Is it correct to assume from your words that an user cannot be in more 
> than one project at the time? If so, can't be overlapping, right?
>
> Best,
> Oliveiros
>
> ----- Original Message ----- From: "Andreas" <maps.on@gmx.net>
> To: <pgsql-sql@postgresql.org>
> Sent: Thursday, June 09, 2011 2:43 PM
> Subject: [SQL] need help with some aggregation magic
>
>
>> hi,
>> I have a log-table that stores events of users and projects like this
>> ( user_id integer, project_id integer, ts timestamp, event_type 
>> integer )
>>
>> I need an aggregated list of worktime per user, per project, per day.
>>
>> The users can switch projects during the day so I can't work this out 
>> with min(ts) and max(ts).
>>
>> Is there a clever way to get this with SQL ?
>>
>> -- 
>> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-sql 
>
>




view thread (7+ messages)  latest in thread

Message-ID: <4DF0F130.5070105@gmx.net>
Permalink:  ../4DF0F130.5070105@gmx.net/
Also on:    postgresql.org/message-id/4DF0F130.5070105@gmx.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: maps.on@gmx.net
  Subject: Re: need help with some aggregation magic
  In-Reply-To: <4DF0F130.5070105@gmx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox