[英]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.