将货币符号附加到 sql 查询的结果 [英] append currency symbol to result of sql query
本文介绍了将货币符号附加到 sql 查询的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一个sql查询的结果
select PayerDate,PaymentAmount from Payments
付款金额 - 十进制
Date Amount
12/11/2012 34.31
12/11/2012 95.60
12/11/2012 34.31
是否可以得到如下查询结果:
is that possible to get the result of query as below:
Date Amount
12/11/2012 $34.31
12/11/2012 $95.60
12/11/2012 $34.31
我已经尝试过,但找不到关于此的太多信息.
I have tried but couldn't find much info on this.
推荐答案
您可以将其连接到您的投影语句中,
you can concatenate it on your projection statement,
<打击>
在 MySQL 中,
SELECT PayerDate, CONCAT('$', PaymentAmount) PaymentAmount
FROM Payments
在 SQL Server 中,
In SQL Server,
SELECT PayerDate, '$' + CAST(PaymentAmount AS VARCHAR(15)) PaymentAmount
FROM Payments
这篇关于将货币符号附加到 sql 查询的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文