List:General Discussion« Previous MessageNext Message »
From:John Meyer Date:April 7 2007 6:23pm
Subject:Re: How can I do something like this in mySQL...
View as plain text  
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
Thread
How can I do something like this in mySQL...John Kopanas7 Apr
  • Re: How can I do something like this in mySQL...John Meyer7 Apr
  • Re: How can I do something like this in mySQL...Mogens Melander8 Apr
    • Re: How can I do something like this in mySQL...John Kopanas8 Apr