错误:函数coalerse(bigint,integer)不存在



我有一个查询,在这里我想返回零值而不是空值。

    create view ct as
    select userid, coalerse(count(tweets), 0) as nooftweets, coalerse(count(distinct mention), 0) as mention 
from (
    select t.user_id as userid, t.id as tweets, m.mentionedusers_id as mention, row_number() over (partition by m.tweet_id order by m.mentionedusers_id
      ) rn 
    from "tweet_mentUsers" m right join tweet t on m.tweet_id = t.id where text like '@%') a where rn <= 2 group by 1

然而,我得到了这个错误消息:

ERROR:  function coalerse(bigint, integer) does not exist
LINE 2: select userid, coalerse(nooftweets, 0), coalerse(mention, 0)...
                       ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

你知道吗?

我认为COALESCE函数可以满足您的需要。

create view ct as
select userid, coalesce(count(tweets), 0) as nooftweets, coalesce(count(distinct mention), 0) as mention 
from (
select t.user_id as userid, t.id as tweets, m.mentionedusers_id as mention, row_number() over (partition by m.tweet_id order by m.mentionedusers_id
  ) rn 
from "tweet_mentUsers" m right join tweet t on m.tweet_id = t.id where text like '@%') a where rn <= 2 group by 1

相关内容

  • 没有找到相关文章

最新更新