我有一个MySQL请求:
SELECT U.*, SUM(P.cost) AS spent FROM `#__users` AS U LEFT JOIN `#__projects` AS P ON P.client_id = U.id WHERE 1=1 AND (spent >= 1000 AND spent < 2000) GROUP BY U.id ORDER BY U.user_creation_timestamp DESC LIMIT 25 OFFSET 0;
但我在这里有错误:
Column not found: 1054 Unknown column 'spent' in 'where clause'
我该如何解决这个问题? 谢谢!
答案 0 :(得分:2)
您无法在哪里使用别名,您无法过滤聚合功能,以及必须使用的过滤器聚合功能
a0