MySQL Forums
Forum List  »  Newbie

Re: IF Statement - does nesting order matter?
Posted by: Peter Brawley
Date: November 14, 2017 10:31PM

> Can the true statement have multiple operations listed?

You mean you want the displayed result to show a list of the comparisons that went into it? You could write out the conditions as a matrix of 1 and 0s ...

  if( qty_prod=0, 1, 0 )                                    as 'zero',
  if( qty_prod < (0.5*max_prod_5, 1, 0 )                    as '< 50% 5yr avg',
  if( qty_prod between avg_prod_5 and avg_prod_1, 1, 0 )    as 'in 5-10 yr range',
  if( qty_prod >= avg_prod_10 and area_change_a > 0, 1, 0 ) as '>10 yr avg',
  if( area_change_a < 0, -1, if( area_change=0, 0, 1 )      as 'area_change'
from fao_aquaculture;

... then combine & describe them as desired in an outer query.

Options: ReplyQuote

Written By
Re: IF Statement - does nesting order matter?
November 14, 2017 10:31PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.