有两个表,一个是产品名称、收入、货币,另一个是货币 & 率
我需要根据费率转换收入:
喜欢:If Table1.Currecy = Table2.Currecy_code then 收入 * rate else 'NA'
这是一长串货币。
你能告诉我哪个查询可以得到这个结果。
仅供参考:我正在使用 Athena database-dbeaver,不确定是哪个 sql。
答案 0 :(得分:0)
您可以使用带有 case when
表达式的左连接
select Product_name,currency,
(case when rate is null then 'NA' else cast(revenue* rate as varchar2) end) revenue
from table1 left join table2 on Table1.Currecy = Table2.Currecy_code