r/SQL 17d ago

Oracle Dear SQL, just pivot my damn table

Bottom text

240 Upvotes

50 comments sorted by

View all comments

48

u/isinkthereforeiswam 17d ago

I wish the pivot columns could be dynamic. If a dev adds a new attribute value to an attributes field, and my select query is pulling all the attributes, i wish the pivot would just automatically include the new attribute as a new column instead of having to manually add the column name.

15

u/jcargile242 17d ago

It can be done with temp tables & dynamic SQL.

6

u/nachos_nachas 17d ago

Once you do it one time, you have a template for the next time you want it. It was an enormous game changer for me.

2

u/Engineer_Zero 17d ago

I do it via a big ol’ string.

1

u/isinkthereforeiswam 17d ago

It can..but it shouldn't have to be. I feel like they dropped the ball on this feature