我想将所有NULL值填充为零 根据我的搜索,我尝试使用coalesce。 我通过PSQL报告错误编写了以下代码:
列“coalesce”指定了多次
我想知道为什么以及如何解决它。
select country.name as name, country.electoral_system,
coalesce(table4_single.single_party,0),
coalesce(table4_two_to_three.two_to_three,0),
coalesce(table4_four_to_five.four_to_five,0),
coalesce(table4_six_or_more.six_or_more,0)
答案 0 :(得分:2)
使用coalesce()
。这应该有效:
select country.name as name, country.electoral_system,
coalesce(table4_single.single_party, 0) as single_party,
coalesce(table4_two_to_three.two_to_three, 0) as two_to_three,
coalesce(table4_four_to_five.four_to_five, 0) as four_to_five,
coalesce(table4_six_or_more.six_or_more, 0) as six_or_more
from table4 join
country
on . . .;