gpt4 book ai didi

mysql - 计算

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

我想返回简单计算的结果,但我不确定如何执行此操作。我的表格如下:

SELECT
COUNT(fb.engineer_id) AS `total_feedback`,
SUM(fb.rating) AS `total_rating`, fb.engineer_id
FROM
`feedback` AS fb

现在,当我返回结果时,我使用 PHP 进行计算,但现在我想按结果对结果进行排序(此查询嵌套在一个更大的查询中)。

计算如下:

$p = ((($total_rating*20)*$total_feedback)/10);

这可以在初始查询中完成吗?

最佳答案

你可以做到

SELECT
COUNT(fb.engineer_id) AS `total_feedback`,
SUM(fb.rating) AS `total_rating`, fb.engineer_id
FROM
`feedback` AS fb
ORDER BY total_rating*20*total_feedback/10

或者如果您希望该列出现在结果中:

SELECT
COUNT(fb.engineer_id) AS `total_feedback`,
SUM(fb.rating) AS `total_rating`, fb.engineer_id
total_rating*20*total_feedback/10 AS p
FROM
`feedback` AS fb
ORDER BY p

关于mysql - 计算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8997383/

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