I have below table
CREATE TABLE bar (project,month,hours)
AS VALUES
('A', 'aug', 1 ),
('A', 'sep', 3 ),
('B', 'aug', 2 ),
('B', 'sep', 5 );
I can crosstab this with month as category as below
select * from crosstab (
'select project, month, hours from bar',
'select distinct month from bar'
) as
c (project text, aug int, sep int);
The problem is month column can be vary. it can be vary from number or names.
Ex: Next time month column in bar table can have oct also which I don't know beforehand.
Then How I create crosstab query for that? In summary what I want is to remove hardcoded aug, sep from my crosstab query.