I have a dataset that looks something like this:
I'd like to aggregate all co
values on one row, so the final result looks something like:
Seems pretty easy, right? Just write a query using crosstab
, as suggested in this answer. Problem is that requires that I CREATE EXTENSION tablefunc;
and I don't have write access to my DB.
Can anyone recommend an alternative?
Conditional aggregation:
SELECT co,
MIN(CASE WHEN ontology_type = 'industry' THEN tags END) AS industry,
MIN(CASE WHEN ontology_type = 'customer_type' THEN tags END) AS customer_type,
-- ...
FROM tab_name
GROUP BY co
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With