我有一个交叉表函数,过去曾多次成功使用过,但现在它在最后转储所有数据,而不是将其转储到输出表中。似乎找不到交叉表。我对其进行了以下研究;
下面是一段函数代码: BEGIN str := '" " text,'; -- A1 单元格中的空白
FOR rec IN SELECT DISTINCT col_name FROM an_in_tbl ORDER BY col_name LOOP str := str || '"' || rec.col_name || '" 文本' ||','; 结束循环;
str:= substring(str, 0, length(str));
EXECUTE 'CREATE EXTENSION IF NOT EXISTS tablefunc;
DROP TABLE IF EXISTS an_out_tbl;
CREATE TABLE an_out_tbl AS
SELECT *
FROM crosstab(''select row_name, col_name, row_value from an_in_tbl order by 1'',
''SELECT DISTINCT col_name …Run Code Online (Sandbox Code Playgroud)