在PostgreSQL中,我动态地生成了逗号分隔的所需列的字符串。但是如何将它们转换为列名?
我在SQL Server中尝试过它..获得成功但想在postgreSQL中做到
我的逗号分隔字符串为: String_agg
7_headid,7_grade,8_headid,8_grade,6_headid,6_grade,5_headid,5_grade,4_headid,4_grade,3_headid,3_grade,15_headid,15_grade,9_headid,9_grade,1_headid,1_grade,2_headid,2_grade
必需输出为:
Column name --> Sr.No || 7_headid || 7_grade || 8_headid || 8_grade || 6_headid ||6_grade || So on ----------------------------------------------------------------------- Rows value --> 1 2 3 4 5 6 7
答案 0 :(得分:1)
SELECT 1 AS "Str. No"
, 2 AS "7_headid"
, 3 AS "7_grade"
...
你必须double-quote identifiers这些违反基本规则。