Re: Tough Problem -- Record Checkouts

From: Greg Stark <gsstark(at)mit(dot)edu>
To: "Alfred" <99m(at)myway(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Tough Problem -- Record Checkouts
Date: 2006-02-18 07:58:03
Message-ID: 87bqx514l0.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


"Alfred" <99m(at)myway(dot)com> writes:

> CO | N
> ------+-----------------------
> 0 | 15-59
> 1 | 0, 16-59
> 2 | 0-1, 17-59
> 15 | 0-14, 30-59
> 16 | 0-15, 31-59
> 30 | 0-29, 45-59
> 31 | 0-30, 46-59
> 45 | 0-44
> 46 | 1-45
> 59 | 14-58
>
> This becomes some kind of UPDATE statement with a complex WHERE clause.

That's usually a sign you're storing the data in the wrong form. Why are you
storing just the minutes and not the absolute timestamp of the checkout?

In any case the where clause isn't all that complex. I think you've confused
yourself by drawing the inverse table of what you need. You need the range of
CO to expire for a given N, not the range of N in which you should expire a
given CO.

WHERE co BETWEEN 0 AND n-15 OR co BETWEEN n+1 AND n+45

--
greg

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Milorad Poluga 2006-02-18 13:44:05 Interval subtracting
Previous Message Greg Stark 2006-02-18 07:36:25 Re: view of weekly data