Hello. Does anyone know why this does not work? I am trying to call all records with a 'rate' of less than 8000. It works until I put in the 'rate' condition. Any help is much appreciated, thankyou. Jamie. select ROUND ((mixact / TIMEDIFF(PROD.timemixfin,PROD.timemixstart)*6000)/COUNT(mixact),0) as rate from PROD where 'rate' < '8000' group by PROD.index ORDER BY PROD.time Code (markup):
Just to expand on @PoPSiCLe's answer quotes '' go around values ticks `` go around column names and table names so your query could look like this select ROUND ((`mixact` / TIMEDIFF(`PROD`.`timemixfin`, `PROD`.`timemixstart`)*6000)/COUNT(`mixact`),0) as `rate` from PROD where `rate` < '8000' group by `PROD`.`index` ORDER BY `PROD`.`time` Code (markup): It's particularly handy when there is a chance that a table or column name could be confused with a MySQL reserved word.
Thanks fella's, but that does not work. Getting the same problem. Say's "Unkown column 'rate' in where claus. Rate is not a column name, it's a name I put in the statement to identify the calculated 'rate' within the statemant. Any other clues please? Jamie.
aaah, yes. try this select ROUND ((`mixact` / TIMEDIFF(`PROD`.`timemixfin`, `PROD`.`timemixstart`)*6000)/COUNT(`mixact`),0) as `rate` from PROD group by `PROD`.`index` HAVING`rate` < '8000' ORDER BY `PROD`.`time` Code (markup):
Thankyou Sarahk! That has done the trick. Never used the 'HAVING' condition before. Thanks posicle for trying also. Best Wishes. Jamie.