PostgreSQL: Getting result of a function in a single column in PostgreSQL -
trying display result in form of table different columns, getting result in single column.
--my function
create or replace function test1()        returns table ( "fname" varchar(20),"lname" varchar(20),"a-b" bigint,"c-d" bigint, "e-f" bigint )     $body$   begin   return query   select tb."fname",tb."lname",count(tb."city"='a-b' or null) "a-b",      count(tb."city"='c-d' or null) "c-d",      count(tb."city"='e-f' or null) "e-f"   "table1" tb      tb."city" in ('a-b','c-d','e-f')     group 1,2   order 1,2;     end   $body$   language plpgsql;   
in instead of
select test1() do
select * test1() 
Comments
Post a Comment