Page 1 of 1

Filter on TZQuery

Posted: 27.08.2007, 09:09
by bedfordch
I've version 6.1.5, Delphi 6 enterprise and Mysql database.
In a TZQuery I've this SQL:

select id, sum(amount1) as total1, sum(amount2) as total2,
sum(amount3) as total3, sum(amount1+amount2+amount3) as total
from orders
group by id

Now I'm trying to apply a filter on a field in this query:
ordertype < 12
Problem: it doesn't seem to work. With or without filter, the result is the same. I've tried to apply ordertype < 1 to reduce the number of records but the result is always the same. What's wrong ? filter doesn't work on totals ?
Thanks for helping, it's 2 day I'm on this problem.
Bob

Posted: 27.08.2007, 11:40
by Michael
erm ... where is the "ordertype" in your query :gruebel:

If you want to reduce the records to be summed up you have to include a where clause in your statement. otherwise you have to include "ordertype" in your select and group by statement.