Skip to content
Advertisement

Pivot by Country Name and Flag in Postgresql

and I am trying to cross tab it like this:

Here is my SQL query,

I am not able to do it since I do not have permissions to create extensions (tablefunc)

Is there an alternate way?

Can you please help? Thank you.

Advertisement

Answer

As you ave only 2 values, you can make the classical approach to pivot

country | correct | incorrect
:------ | ------: | --------:
Algeria |       5 |         1
USA     |     486 |        21

a_horse_with_no_name pointed out, that there is also an alternative

country | correct | incorrect
:------ | ------: | --------:
Algeria |       5 |         1
USA     |     486 |        21

db<>fiddle here

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement