Re: Calculation of per Capita on-the-fly - problems with SQL syntax - Mailing list pgsql-general

From Sam Mason
Subject Re: Calculation of per Capita on-the-fly - problems with SQL syntax
Date
Msg-id 20071015161935.GB10098@samason.me.uk
Whole thread Raw
In response to Re: Calculation of per Capita on-the-fly - problems with SQL syntax  (Stefan Schwarzer <stefan.schwarzer@grid.unep.ch>)
List 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

pgsql-general by date:

Previous
From: "Trevor Talbot"
Date:
Subject: Re: atomic commit;begin for long running transactions , in combination with savepoint.
Next
From: Michael Glaesemann
Date:
Subject: Re: Calculation of per Capita on-the-fly - problems with SQL syntax