G
CREATE OR REPLACE FUNCTION ten(integer) RETURNS table(f1 text, f2 integer, f3 integer, f4 integer)
AS
'
select
case
when types.id=1 then 'квартира'
when types.id=2 then 'дом'
when types.id=3 then 'ап-ты'
end, count(*), count(*)*100/newcolumn, sum(sale.cost_sale)
from types, objects, sale, (select count(*) as newcolumn from sale where extract(year from date_sale)=$1) newtable
where sale.id_object=objects.id
and objects.type=types.id
and extract(year from sale.date_sale)=$1
group by types.id, newcolumn
'
LANGUAGE SQL;
select * from ten(2021);
Код ошибки:
ERROR: ОШИБКА: ошибка синтаксиса (примерное положение: "квартира")
LINE 6: when types.id=1 then 'квартира'
а это постгре? вопрос снимается


