简体   繁体   English

没有函数匹配给定的名称和参数类型。 您可能需要添加显式类型转换 - Postgresql(IF 函数)

[英]No function matches the given name and argument types. You might need to add explicit type casts - Postgresql (IF function)

I tried to run the below query:我尝试运行以下查询:

SELECT account_no, month_id, IF (product_category = 'Services', 'ServicesMarketing', product_category) AS product_category, revenue  
FROM public.revenue_raw_data

Error I got:我得到的错误:

 ERROR: function if(boolean, unknown, character) does not exist LINE 1: SELECT account_no, month_id, IF (product_category = 'Service... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. SQL state: 42883 Character: 30

My Data:我的数据:

查看我的数据的样子

There is no IF() function in SQL (or in Postgres). SQL(或 Postgres)中没有IF()函数。

In Postgres (and standard SQL) you would use a CASE expression在 Postgres(和标准 SQL)中,您将使用 CASE 表达式

SELECT account_no, month_id, 
       case 
         when product_category = 'Services'
              then 'ServicesMarketing'
         else product_category
       end AS product_category, 
       revenue 
FROM public.revenue_raw_data

(Note that I am just guessing what you think that if() should do) (请注意,我只是在猜测您认为if()应该做什么)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PGSql 没有函数匹配给定的名称和参数类型。 您可能需要添加显式类型转换 - PGSql No function matches the given name and argument types. You might need to add explicit type casts postgresql 交叉表语法错误:没有函数匹配给定的名称和参数类型。 您可能需要添加显式类型转换 - postgresql Cross Tab syntax error: No function matches the given name and argument types. You might need to add explicit type casts 没有运算符与给定的名称和参数类型匹配。 您可能需要添加显式类型转换——PostgreSQL 14.1 - No operator matches the given name and argument types. You might need to add explicit type casts -- PostgreSQL 14.1 Postgres 错误:没有过程匹配给定的名称和参数类型。 您可能需要添加显式类型转换 - Postgres error: No procedure matches the given name and argument types. You might need to add explicit type casts SQLSTATE [42883]:未定义的函数,您可能需要添加显式类型强制转换 - SQLSTATE[42883]: Undefined function You might need to add explicit type casts PostgreSQL:否 function 匹配给定的名称和参数类型。 每周用户登录队列分析 - PostgreSQL: No function matches the given name and argument types. Weekly user login cohort analysis 没有函数匹配给定的名称和参数类型。 在带有 python 的 postgres 中 - No function matches the given name and argument types. in postgres with python PostgreSQL:没有函数匹配给定的名称和参数类型 - PostgreSQL: No function matches the given name and argument types PostgreSQL DBLink:没有函数匹配给定的名称和参数类型 - PostgreSQL DBLink: No function matches the given name and argument types web2py错误:您可能需要添加显式类型转换 - web2py error: You might need to add explicit type casts
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM