![](/img/trans.png)
[英]PGSql No function matches the given name and argument types. You might need to add explicit type casts
[英]No function matches the given name and argument types. You might need to add explicit type casts - Postgresql (IF function)
我嘗試運行以下查詢:
SELECT account_no, month_id, IF (product_category = 'Services', 'ServicesMarketing', product_category) AS product_category, revenue
FROM public.revenue_raw_data
我得到的錯誤:
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
我的數據:
SQL(或 Postgres)中沒有IF()
函數。
在 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
(請注意,我只是在猜測您認為if()
應該做什么)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.