Re: partitioning a dataset + employing hysteresis condition - Mailing list pgsql-general

From Gavin Flower
Subject Re: partitioning a dataset + employing hysteresis condition
Date
Msg-id 4EC2E138.5050303@archidevsys.co.nz
Whole thread Raw
In response to Re: partitioning a dataset + employing hysteresis condition  (Amit Dor-Shifer <amit.dor.shifer@gmail.com>)
List pgsql-general
On 14/11/11 18:35, Amit Dor-Shifer wrote:

On Mon, Nov 14, 2011 at 4:29 PM, Amit Dor-Shifer <amit.dor.shifer@gmail.com> wrote:
Hi,
I've got this table:
create table phone_calls
(
    start_time timestamp,
    device_id integer,
    term_status integer
);

[…]

3 points

POINT 1:
I should have given the results of my attempt...


[...]
device_id
-----------
2
40
50
60
(4 rows)


POINT 2:
I also realized I left of a condition in the HAVBING part

HAVING
    max(pc1.start_time) >= min(pc1.start_time) + interval '2 minute'

I think it should be

HAVING
        max(pc1.start_time) >= min(pc1.start_time) + interval '2 minute'
    AND pc1.term_status = 2


POINT 3:
Timestamps should almost always be stored with a time zone (using timestamptz rather than just timestamp) – or you will have problems when Summer time ends or begins, and using timestamptz allows for date&time to be displayed currectly in different locales.


Regards,
Gavin

P.S. Since my post has not shown up yet, I had to attach to its parent!
(I won't offer my first born to get direct posting rights,
as his wife may object -
besides which, it is probably illegal in my jurisdiction!)

pgsql-general by date:

Previous
From: Gavin Flower
Date:
Subject: Re: partitioning a dataset + employing hysteresis condition
Next
From: David Johnston
Date:
Subject: Re: partitioning a dataset + employing hysteresis condition