Re: Calculation of per Capita on-the-fly - problems with SQL syntax

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Calculation of per Capita on-the-fly - problems with SQL syntax
Date: 2007-10-15 16:19:36
Message-ID: 20071015161935.GB10098@samason.me.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Oct 15, 2007 at 02:08:24PM +0200, Stefan Schwarzer wrote:
> Just one thing: As my year columns can have as well values like "1970-75",
> they are not integers, but text fields. Thus, the "IN" parameter in the
> "WHERE" clause doesn't work. Do you have any other idea how ti could work?

I'd be tempted to split your "year" column (maybe more appropriately
named as "year range") into two integer columns, one for the start year
and one for the end year. Once you've done that it would become much
easier to write queries. Generally, you want to split the information
that the database uses into one piece per column. If you do split it
then you could do something like:

WHERE d.year_min <= 2004 AND d.year_max >= 2002

Sam

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Glaesemann 2007-10-15 16:21:30 Re: Calculation of per Capita on-the-fly - problems with SQL syntax
Previous Message Trevor Talbot 2007-10-15 16:09:57 Re: atomic commit; begin for long running transactions , in combination with savepoint.