我有如下查询
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
语句中的列别名。
我是一名优秀的程序员,十分优秀!