我正在尝试运行查询,但是在'where子句'中出现了“未知列'MyField'”错误。
这是我的疑问:
SELECT id, sum(lineValue * quantity) as TotalLine
FROM myTable
WHERE (TotalLine BETWEEN 10 and 500)
group by id
如何执行类似的查询? 感谢
答案 0 :(得分:7)
SELECT id, SUM(lineValue * quantity) as TotalLine
FROM myTable
GROUP BY
id
HAVING TotalLine BETWEEN 10 and 500