AS子句這實際上是一個跟進Dynamically generate columns for crosstab in PostgreSQL動態生成的Postgres交叉
要明確:如果我有鑰匙的可變數目我不能生成AS子句的數據集?
例如, 與測試(testdate,瞳孔,結果)最初與學生的表格(湯姆,迪克,哈里)
造成這種情況的交叉將是:
select * from crosstab(
'select testdate, pupil, result from tests)',
'select distinct pupil from tests order by pupil')
as ct
(
"testdate" text,
"Dick" text,
"Harry" text,
"Tom" text)
將盡快薩莉加入失敗?類似於
ERROR: invalid return type
DETAIL: Query-specified return tuple has 4 columns but crosstab returns 5.