[英]Expand column into multiple columns in postgres
Basically this is the result that I get from the fiddle that you can find here: http://sqlfiddle.com/#!17/48a30/59 基本上这是我从小提琴中得到的结果,您可以在这里找到: http ://sqlfiddle.com/#!17/48a30/ 59
My question is how can you turn the result below 我的问题是如何将结果转为下面
update_record
(1,t)
(null)
(3,t)
(null)
(5,t)
(null)
into the following 进入以下
col1 | col2
-----+-----
1 | t
3 | t
5 | t
Basically, functions which return set of rows should be called in the FROM clause. 基本上,应该在FROM子句中调用返回行集的函数。 In this way you will get regular columns instead of records in the resultset.
这样,您将获得常规列而不是结果集中的记录。
SELECT upd.*
FROM input,
update_record(input) AS upd
WHERE upd.id IS NOT NULL
id | certified
----+-----------
1 | t
3 | t
5 | t
(3 rows)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.