gpt4 book ai didi

mysql - 从 mysql 操作打印五个字符串

转载 作者:行者123 更新时间:2023-11-29 08:45:51 26 4
gpt4 key购买 nike

这是我的查询

$sum = "SELECT htno, 
SUM(tm) AS tech,
SUM(tm)/7.5 AS divi,
SUM(credits) AS cred ,
SUM(CASE WHEN credits <= 0 THEN 1 ELSE 0 END) AS log,
SUM(CASE WHEN credits > 0 THEN 1 ELSE 0 END) AS pass,
SUM(CASE WHEN em >= 0 THEN 1 ELSE 0 END) AS atm,
SUM(CASE WHEN em >= -2 THEN 1 ELSE 0 END) AS tot
FROM jbit WHERE htno='$id'";

在第三行“SUM(tm)/7.5 As divi”查询中,输出为 79.2544555555,但我希望输出为 79.25

friend 们帮帮忙

最佳答案

您可以使用 TRUNCATE() :

TRUNCATE(SUM(tm)/7.5 , 2) AS divi,

截断将为您提供 '1.259' 的 '1.25' ,如果您希望将其四舍五入,则使用:

ROUND(SUM(tm)/7.5 , 2) AS divi,

这将为您提供“1.259”的“1.26”

关于mysql - 从 mysql 操作打印五个字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12545083/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com