相关疑难解决方法(0)

为 Postgres 中提取的列列表中的值创建数组

我有以下一组表:

id   column_a  column_b   column_c
1     t          f           t
2     t          f           f
3     f          t           f
Run Code Online (Sandbox Code Playgroud)

当被查询时:

SELECT bool_or(column_a) AS column_a
     , bool_or(column_b) AS column_b
     , bool_or(column_c) AS column_c
FROM   tbl
WHERE  id IN (1,2);
Run Code Online (Sandbox Code Playgroud)

结果如下:

column_a   column_b   column_c
 t          f            t
Run Code Online (Sandbox Code Playgroud)

我想从结果中获取数组:[t,f,t]在 Postgres 中。

请在此处参考较早的堆栈问题。

sql arrays postgresql aggregate-functions

6
推荐指数
1
解决办法
3037
查看次数

标签 统计

aggregate-functions ×1

arrays ×1

postgresql ×1

sql ×1