小编Oma*_*mat的帖子

COALESCE 类型字符变化和数字无法匹配

table1我有一个以 columnsGender varchar(10)和命名的表Team numeric

create table table1 (
ID integer
Gender varchar(10),
Team numeric
);

insert into table1 (ID,Gender,Team) values
(1,'M',NULL),
(2,NULL,10),
(3,NULL,6),
(4,''F',NULL),
(5,NULL,3);
Run Code Online (Sandbox Code Playgroud)

我想创建一个新列,因为Nxt它返回任何列中不为空的行,无论是字符串还是整数。

该列Nxt将如下所示:M,10,6,F,3

我试过这个:

select coalesce(Gender,Team) as value from table1;
Run Code Online (Sandbox Code Playgroud)

它返回此错误:

COALESCE 类型字符变化和数字无法匹配

postgresql coalesce

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

coalesce ×1

postgresql ×1