Answer the question
In order to leave comments, you need to log in
How to create PostgreSQL table function with column names as arguments?
Good day to all.
Got a team
select supplier, car_category, count(car_type) from mytable group by 1,2 order by 1,2;
create or replace function pivot_car_type(a text, b text, c text)
returns table(supplier text, category text, car_type_qty bigint) as
$$
begin
return query
select a,b,count(c) from avis.rateshop group by 1,2 order by 1,2;
end;
$$
language 'plpgsql';
select * from pivot_car_type(supplier, car_category, car_type);
select 'supplier', 'car_category', count('car_type') from mytable group by 1,2 order by 1,2;
select supplier, car_category, count(car_type) from mytable group by 1,2 order by 1,2;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question