Re: Function fixing - PostgreSQL 9.2

Поиск
Список
Период
Сортировка
От drum.lucas@gmail.com
Тема Re: Function fixing - PostgreSQL 9.2
Дата
Msg-id CAE_gQfUPMf40qygH9A0JLoEtvMXt6Rz2SyyjE=48bfLZfYZwOw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Function fixing - PostgreSQL 9.2  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: Function fixing - PostgreSQL 9.2  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general


On 1 March 2016 at 11:35, David G. Johnston <david.g.johnston@gmail.com> wrote:
On Mon, Feb 29, 2016 at 2:56 PM, drum.lucas@gmail.com <drum.lucas@gmail.com> wrote:

Question:

Payments in a Pending state cannot be invoiced and are excluded from the Invoice Runs section, but they are showing in the count mechanic.

How can I solve this?


​In 9.2 you probably need to convert the count into a conditional sum:

SELECT sum(CASE WHEN <boolean> THEN 1 ELSE 0 END) FROM data;

You can probably do the same with count since it excludes nulls.

SELECT count(NULLIF(invoice_status, 'Pending') FROM invoices;

​9.4 introduced a FILTER clause for Aggregate Expressions that can do this much more cleanly and efficiently.​


David J.


Thank you David...

Can you please show me how it would be with the new changes?

Thanks 

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

Предыдущее
От:
Дата:
Сообщение: Looking for pure C function APIs for server extension: language handler and SPI
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Function fixing - PostgreSQL 9.2