Question

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

Was it helpful?

Solution

SELECT  id, SUM(lineValue * quantity) as TotalLine
FROM    myTable
GROUP BY
        id
HAVING  TotalLine BETWEEN 10 and 500
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top