我是PostgreSQL
的新用户,我在array
中使用PostgreSQL
类型
WITH intarr AS (
SELECT
ARRAY [ s.days,s.hours ] ::int[] AS arr
FROM summary s
WHERE s.hours != 2
)
SELECT ARRAY(SELECT * from intarr );
我收到此错误:
[Err]错误:找不到数据类型integer []
的数组类型
我找到了改变方式
ARRAY [ s.days,s.hours ] ::int[] AS arr
到此
行ARRAY [ s.days,s.hours ] ::varchar AS arr
我得到的结果如下:{"{1,3}","{2,3}"}
。但我需要结果int[][]
类型。我如何将one-dimensional array
转换为two-dimensional array
答案 0 :(得分:1)
我现在用它,我不认为它是完美的方式。
WITH intarr AS (
SELECT
ARRAY [ s.days,s.hours ] ::VARCHAR AS arr
FROM
summary s
WHERE
s.hours != 2
)
SELECT replace((SELECT ARRAY(SELECT arr from intarr)::VARCHAR), '"', '')::int[][]