test convert column in rows and get count of different values of same column in postresql
Advertisement
Answer
You can do conditional aggregation. Postgres supports the standard filter()
clause, that comes handy here:
select activity_tag, bank, count(*) filter(where within_beyond = 'WITHIN') within_count, count(*) filter(where within_beyond = 'BEYOND') beyond_count from mytable group by activity_tag, bank