News for hackers. Stuff that matters.
Re:Pivot – Rows to Columns by makmanalp on Monday February 05, 2018 @02:46PM (#16311450)
In postgres you can use the crosstab function with two SQL queries, the first to get the data to pivot, the second to dynamically query the categories from the data (e.g. some kind of SELECT DISTINCT).
Re:Pivot – Rows to Columns by makmanalp on Monday February 05, 2018 @06:07PM (#16313091)
Actually, I just realized I'm wrong. You can do my trick to automatically filter values, but you still have to pre-declare the schema of the table being returned. This means you can't have a dynamic pivot where maybe you end up with 6 columns instead of 5.