What is the alternate of FILTER below Postgresql 9.4 ?

Поиск
Список
Период
Сортировка
От Arup Rakshit
Тема What is the alternate of FILTER below Postgresql 9.4 ?
Дата
Msg-id 10038948.Y5rVLs9M29@linux-wzza.site
обсуждение исходный текст
Ответы Re: What is the alternate of FILTER below Postgresql 9.4 ?  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: What is the alternate of FILTER below Postgresql 9.4 ?  (Andreas Kretschmer <akretschmer@spamfence.net>)
Список pgsql-general
Hi,

Please look at my query :

[shreyas@rails_app_test (master)]$ rails db
psql (9.4.1)
Type "help" for help.

app_development=# select id, location, name from people;
 id | location | name
----+----------+------
  2 | X        | foo
  3 | X        | foo
  4 | Y        | foo
(3 rows)

app_development=# SELECT COUNT(id) FILTER(WHERE lower(location) != 'x') AS Non_X_loc, COUNT(id) FILTER (WHERE
lower(location)= 'x') AS X_loc FROM "people"; 
 non_x_loc | x_loc
-----------+-------
         1 |     2
(1 row)

This *FILTER* method is available from 9.4, How can I get the same output below 9.4 version ?

--
================
Regards,
Arup Rakshit
================
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as
possible,you are, by definition, not smart enough to debug it. 

--Brian Kernighan


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

Предыдущее
От: Guillaume Drolet
Дата:
Сообщение: Re: Sequences not moved to new tablespace
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: What is the alternate of FILTER below Postgresql 9.4 ?