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

Oma*_*mat 8 postgresql 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 类型字符变化和数字无法匹配

小智 12

尝试将该列转换为文本

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