Page 1 of 1

[solved] math in the query

Posted: Fri May 28, 2004 7:34 am
by magicrobotmonkey
I have an sql table with a bunch of fields and I only want to return a result if they sum to 0. this is what I have:

Code: Select all

SELECT report.A1 + report.B1 + report.C1 + report.A2 + report.B2 + report.C2 + report.A3 + report.B3 + report.C3 AS 'Total Lives'
FROM `report` 
WHERE 'Total Lives' > 0
I know the math is working because i can just run the query and Total Lives is right. If I go 'Total Lives' = 0 it returns all results. I'm not exaclty sure whats going on here. Any ideas?

Posted: Fri May 28, 2004 8:05 am
by magicrobotmonkey
never mind, got 'im:

Code: Select all

SELECT report.A1 + report.B1 + report.C1 + report.A2 + report.B2 + report.C2 + report.A3 + report.B3 + report.C3 AS Total
FROM `report` 
HAVING Total > 0 LIMIT 0 , 30