Reputation: 6943
I'm trying to run a query, but I get an "unknown column 'MyField' in 'where clause'" error.
This is my query:
SELECT id, sum(lineValue * quantity) as TotalLine
FROM myTable
WHERE (TotalLine BETWEEN 10 and 500)
group by id
How can I perform a similar query? Thanks
Upvotes: 0
Views: 314
Reputation: 425401
SELECT id, SUM(lineValue * quantity) as TotalLine
FROM myTable
GROUP BY
id
HAVING TotalLine BETWEEN 10 and 500
Upvotes: 7