在 SQL 中,可使用以下方法用于货币转换:
SELECT amount * exchange_rate AS converted_amount
FROM transactions
WHERE currency = 'USD';
SELECT
CASE
WHEN currency = 'USD' THEN amount * usd_to_eur_rate
WHEN currency = 'EUR' THEN amount
ELSE amount
END AS converted_amount
FROM transactions;
以上是两种常见的方法用于货币转换,具体的实现方法可能因数据库类型和表结构而有所不同。在实际应用中,应根据具体情况选择最适合的方法。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:convert函数在sql中有哪些作用