gpt4 book ai didi

mysql - 如何在具有别名的字段上进行 ORDER BY

转载 作者:太空宇宙 更新时间:2023-11-03 10:55:43 25 4
gpt4 key购买 nike

我有如下查询

   SELECT
final_avg_total.`Provider Name`,
ROUND(SUM(final_avg_total.avg_total_payments), 2) AS avg_payments,
ROUND(SUM(final_avg_total.avg_covered_charges), 2) AS avg_covered,
(SUM(final_avg_total.avg_covered_charges) - SUM(final_avg_total.avg_total_payments)) / SUM(final_avg_total.avg_covered_charges) AS total_average,
1 - (SUM(final_avg_total.avg_covered_charges) - SUM(final_avg_total.avg_total_payments))/SUM(final_avg_total.avg_covered_charges) AS total_percentage
FROM final_avg_total
GROUP BY final_avg_total.`Provider Id`
ORDER BY final_avg_total.`avg_payments` DESC

我想在以下字段中使用别名 avg_payments 进行排序,但出现此错误。

 Unknown column avg_payments in the order by clause

最佳答案

avg_payments 不是表中的字段。只需删除表别名:

ORDER BY avg_payments  DESC

MySQL 理解 order by 语句中的列别名。

关于mysql - 如何在具有别名的字段上进行 ORDER BY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20976832/

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