informatica:base_de_datos:postgresql:postgresql_pivot
Diferencias
Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
| informatica:base_de_datos:postgresql:postgresql_pivot [2026/01/28 04:11] – admin | informatica:base_de_datos:postgresql:postgresql_pivot [2026/01/29 02:50] (actual) – admin | ||
|---|---|---|---|
| Línea 6: | Línea 6: | ||
| * [[https:// | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| - | * [[https://learnsql.com/blog/creating-pivot-tables-in-postgresql-using-the-crosstab-function/]] | + | * [[https://stackoverflow.com/questions/3002499/ |
| + | |||
| + | < | ||
| + | |||
| + | CREATE EXTENSION IF NOT EXISTS tablefunc; | ||
| + | |||
| + | CREATE TABLE tbl ( | ||
| + | | ||
| + | , status | ||
| + | , ct integer | ||
| + | ); | ||
| + | |||
| + | INSERT INTO tbl VALUES | ||
| + | (' | ||
| + | (' | ||
| + | (' | ||
| + | (' | ||
| + | (' | ||
| + | |||
| + | |||
| + | SELECT * | ||
| + | FROM crosstab( | ||
| + | ' | ||
| + | FROM tbl | ||
| + | ORDER BY 1, | ||
| + | ) AS ct (" | ||
| + | |||
| + | </code> | ||
informatica/base_de_datos/postgresql/postgresql_pivot.1769573490.txt.gz · Última modificación: 2026/01/28 04:11 por admin
