简体   繁体   中英

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

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. 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)

SQLFiddle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM