Let's say I have a query that returns the following:
| Country |
|---|
| US |
| FR |
| UK |
| IT |
Is it possible to use the result of that query to create a new query with columns as country names like the following:
| US | FR | UK | IT |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
My main goal is to create a new query dynamically in case the number of countries increases in the first query.
I am trying to avoid using postgresql extension tablefunc as it needs to be installed. The production db does not have the crosstab extension installed, so I am trying to avoid it. Thanks!