簡體   English   中英

在postgres中將列擴展為多列

[英]Expand column into multiple columns in postgres

基本上這是我從小提琴中得到的結果,您可以在這里找到: http ://sqlfiddle.com/#!17/48a30/ 59

我的問題是如何將結果轉為下面

update_record
(1,t)
(null)
(3,t)
(null)
(5,t)
(null)

進入以下

col1 | col2
-----+-----
1    | t
3    | t
5    | t

基本上,應該在FROM子句中調用返回行集的函數。 這樣,您將獲得常規列而不是結果集中的記錄。

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。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM