John Kopanas wrote:
> I have a query that looks something like this:
>
> SELECT (c_o_w_inst_rev - c_o_w_estcost)/c_o_w_inst_rev
> FROM tmpGovernmentSummaries
>
> The problem is that sometimes c_o_w_inst_rev is 0 and dividing by zero
> returns a NULL.
>
> If c_o_w_inst_rev == 0 how can I return 0 for the SELECT above instead
> of NULL? Can I test in the SELECT if c_o_w_inst_rev is 0 and return 0
> and if not do the math?
>
> Insight would be greatly appreciated :-)
>
>
http://dev.mysql.com/doc/refman/5.1/en/control-flow-functions.html#function_ifnull
HTH