DEV Community

How to pivot data using Dynamic SQL in SQL Server

Olesia Dudareva on May 22, 2023

SQL Server PIVOT operator is useful when you know all values which should become columns. But if you do not know what is exactly in the table. How ...
Collapse
 
yet_anotherdev profile image
Lucas Barret

I am more used to Postgres and pivoting is not a standard function in it. Really cool to see another technologies thanks for this article.

Collapse
 
rozhnev profile image
Slava Rozhnev

PostgreSQL/MySQL/MariaDB have not built-in pivot operator and use Group By and conditional aggregation. Here Postgre Pivot example

Collapse
 
yet_anotherdev profile image
Lucas Barret

Oh yeah thanks, actually I wrote an article about CROSSTAB in Postgre. If you have any feedback about it please do not hesitate :D

Collapse
 
notte profile image
Olesia Dudareva

Welcome! I am glad that it was interesting and I hope it will be useful or just give an alternative idea how to pivot data.