views:

191

answers:

1

Hi,

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

+7  A: 
SELECT  id, SUM(lineValue * quantity) as TotalLine
FROM    myTable
GROUP BY
        id
HAVING  TotalLine BETWEEN 10 and 500
Quassnoi
thank you so much, Quassnoi
Armadillo