这里我有以下功能,但没有得到如何返回结果。
create or replace function f1() returns void as
$body$
begin
SELECT "Fname",
"Lname",
count("City" = 'A-B' OR NULL) AS "A-B",
count("City" = 'C-D' OR NULL) AS "C-D",
FROM "Table1"
WHERE "City" in ('A-B','C-D')
GROUP BY 1,2
ORDER BY 1,2
答案 0 :(得分:2)
将返回类型更改为RETURNS TABLE (fieldname type, fieldname type, ...)
并使用RETURN QUERY SELECT ...
。