melkij=> \da pg_catalog.sum
Список агрегатных функций
Схема | Имя | Тип данных результата | Типы данных аргументов | Описание
------------+-----+-----------------------+------------------------+--------------------------------------------------
pg_catalog | sum | numeric | bigint | sum as numeric across all bigint input values
pg_catalog | sum | double precision | double precision | sum as float8 across all float8 input values
pg_catalog | sum | bigint | integer | sum as bigint across all integer input values
pg_catalog | sum | interval | interval | sum as interval across all interval input values
pg_catalog | sum | money | money | sum as money across all money input values
pg_catalog | sum | numeric | numeric | sum as numeric across all numeric input values
pg_catalog | sum | real | real | sum as float4 across all float4 input values
pg_catalog | sum | bigint | smallint | sum as bigint across all smallint input values
select
region_code, ...
sum(case when status_id = 2 then 1 else 0 end) - sum(case when consul_need_id = 3 then 1 else 0 end) as diff, ...
select t.*,
"Всего детей",
"Всего детей" - "18.1",
"18.1" * "До года жизни" / ("7.1" + "8.1")
...
from (
select
region_code, sum(case when age_group_id < 13 then 1 else 0 end) as "До года жизни",
....
) t
(sum(case when ... end),0)
- зачем оно вам? <message>
и вытащить значение через регэкспы или тупо с find()
.