Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux