0

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!

3
  • Crosstab questions Commented Nov 21, 2022 at 10:33
  • I don't want to install an extension to the prod db unless it is not possible to accomplish this task without crosstab extension. Commented Nov 21, 2022 at 10:38
  • You don't need the crosstab extensions. See here or here or here or here or here Commented Nov 21, 2022 at 10:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.