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

Поиск
Список
Период
Сортировка
От Stefan Schwarzer
Тема Re: Calculation of per Capita on-the-fly - problems with SQL syntax
Дата
Msg-id B37455BB-F931-40F0-A6EE-33E4AA7AEC5A@grid.unep.ch
обсуждение исходный текст
Ответ на Re: Calculation of per Capita on-the-fly - problems with SQL syntax  (Nis Jørgensen <nis@superlativ.dk>)
Ответы Re: Calculation of per Capita on-the-fly - problems with SQL syntax  (brian <brian@zijn-digital.com>)
Re: Calculation of per Capita on-the-fly - problems with SQL syntax  (Sam Mason <sam@samason.me.uk>)
Список pgsql-general
> This should give you the same data out in a different format. Note
> that
> most of the NULL values will be excluded from this result.
>
> SELECT cname, year, d.value/pt.value
> FROM
>     public_multiple_tables.agri_area AS d
> INNER JOIN
>      public_multiple_tables.pop_total AS pt ON pt.id_country =
> d.id_country AND pt.year = d.year
> INNER JOIN
>     countries_view AS c ON c.id = d.id_country
> WHERE d.year in (2002,2003,2004)
> AND pt.value <> 0
> ORDER by c.name, year;

Ah... Thanks a lot for that.

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?

Thanks a lot for your help!

Stef

В списке pgsql-general по дате отправления:

Предыдущее
От: "Filip Rembiałkowski"
Дата:
Сообщение: Re: pg_dump - schema diff compatibility
Следующее
От: Joao Miguel Ferreira
Дата:
Сообщение: Re: replicating to a stopped server