SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table a (a int, b int); insert into a values (1,2),(3,4); create table b (a int, b int, c int); insert into b values (1,2,10),(3,4,20); select json_agg(row_to_json(a.*)) from a; create function f(t text) returns setof json language plpgsql as $$ begin if t = 'a' then select json_agg(row_to_json(a.*)) from a; else select json_agg(row_to_json(b.*)) from b; end if end $$ select * from f('a');
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear