非常新的SQL。尝试仅在TotalSales小于目标时才显示结果。
SELECT SUM(Table1.Column1) AS TotalSales
FROM Table 1
WHERE Table1.Goal > TotalSales
GROUP BY EmployeeID;
它给了我错误1054:未知列。
同样,非常基本,但我被卡住了。再次感谢您的帮助。
答案 0 :(得分:-1)
subquery
需要JOIN
:
SELECT t1.*, t2.TotalSales
FROM TABLE1 t1 INNER JOIN (
SELECT EmployeeID, SUM(Table1.Column1) AS TotalSales
FROM Table1
GROUP BY EmployeeID ) t2
ON t1.EmployeeID = t2.EmployeeID
WHERE t1.Goal > t2.TotalSales;