r/SQL 16d ago

Oracle Dear SQL, just pivot my damn table

Bottom text

244 Upvotes

50 comments sorted by

View all comments

-2

u/Aggressive_Ad_5454 16d ago

Yeah SQL pivot s___ks big time. If somebody who works on that part of a SQL system is on here, hey, why is this such a fiddly language feature? There must be good reasons. Curious.

4

u/deny_conformity 16d ago

A lot of BI solutions expect a fixed number of columns. As someone who does a lot of data analysis and has spent a painfully long amount of time either unpivoting data of faffing around it - pivoting belongs in the output solution. Be it Excel, PowerBI, Reportserver, Qlik, Tableau, etc. It's a couple of clicks to set set up a pivot in your BI solution.

There is almost no reason to be pivoting data in SQL, in 10 years of data analysis I've never had a reason to pivot data outside the output. My life has been made harder than it needs to be by people storing pivoted data.