Reputation: 6733
Here i have following function, but not getting how to return the result.
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
Upvotes: 0
Views: 113
Reputation: 324295
Change the return type to RETURNS TABLE (fieldname type, fieldname type, ...)
and use RETURN QUERY SELECT ...
.
See the PL/PgSQL docs.
Upvotes: 2