【发布时间】:2021-12-03 11:12:05
【问题描述】:
您好,我创建了一个视图,但我想用动态年份来旋转它。
旋转前的输出:
预期输出:
我的查询:
SELECT *
FROM crosstab(
' select b.jenisiuran,
date_part(''year''::text, a.insertdate) AS tahun,
sum(b.jumlah_amt) AS jumlah
FROM blm_dpembayaraniuran a
JOIN blm_dpembayaraniuranline b ON a.blm_dpembayaraniuran_key::text = b.blm_dpembayaraniuran_key::text
GROUP BY date_part(''year''::text, a.insertdate), b.jenisiuran'
) AS (TRANSAKSI TEXT, "2019" NUMERIC, "2020" NUMERIC, "2021" numeric);
我收到这样的错误:
ERROR: invalid return type
Detail: SQL rowid datatype does not match return rowid datatype.
谢谢你帮助我
【问题讨论】:
-
为什么要加入数据类型不同的列?从连接条件中转换两个(甚至一个)列似乎是一件非常奇怪的事情。
标签: postgresql pivot crosstab