问题描述
可能的重复:
MySQL 查询 - 'CAST' 'CONCAT' - 如何将多行数据乘以一定数量并以英镑为单位在新列中显示它们各自的总数?
这是我的查询,但我想通过将计数乘以 1.50 英镑在总价列中显示以英镑为单位的值.目前他们只是显示BLOB"值,我做错了什么?我无法弄清楚,非常感谢任何帮助...
here's my query, but I want to show values in £ in the total price column by multiplying the count by £1.50. Currently they are just showing 'BLOB' values, what am I doing wrong? I can't figure it out, any help greatly appreciated...
SELECT CONCAT_WS(" ", c.customer_title, c.customer_fname, c.customer_sname) AS Customer,
COUNT(O.order_name) AS Ordertotal, concat('£' * 1.5) TotalPrice
FROM Order O, Friend F, Customer C, FriendOrder
WHERE C.customer_id = F.Customer_id
AND F.Friend_id = FriendOrder.friend_id
AND O.order_id = FriendOrder.order_id
GROUP BY Customer
ORDER BY C.customer_sname, C.customer_fname
结果:p.s 出于保密原因,我已将客户姓名列排除在外
Result: p.s I've left the customer names column out for confidentiality reasons
Name COUNT totalPrice
4 BLOB
2 BLOB
1 BLOB
3 BLOB
3 BLOB
3 BLOB
1 BLOB
1 BLOB
2 BLOB
3 BLOB
2 BLOB
推荐答案
您将字符串 '£'
乘以数字 1.5
.我不完全确定它的作用是什么,但它肯定达不到您想要的效果.
You are multiplying the string '£'
by the number 1.5
. I'm not entirely sure what that does, but it certainly doesn't achieve what you want.
尝试:
CONCAT('£', COUNT(*) * 1.5)
这篇关于MYSQL 查询 - 如何通过执行 CONCAT 并使用正确的乘法总值创建新列来显示正确的值,而不是 blob?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!