Subject | RE: [firebird-support] "divison by 0" question |
---|---|
Author | Alan McDonald |
Post date | 2007-05-10T09:59:01Z |
>CASE WHEN I.PRICE=0
> I have a query that looks something like:
> SELECT
> S.PRICE SALEPRICE,
> E.PRICE ENTRYPRICE,
> (S.PRICE -I.PRICE)/I.PRICE PERCENT
> FROM SALES S, ENTRYS E
> WHERE S.IDENTRY = E.ID
>
> The problem is that I.PRICE can be 0 and i get a division by 0 error. Is
> there a way to make PERCENT = 100 if I.PRICE = 0 without running
> two querys?
>
> SELECT
> S.PRICE SALEPRICE,
> E.PRICE ENTRYPRICE,
THEN 100
ELSE
> (S.PRICE -I.PRICE)/I.PRICEEND PERCENT
> FROM SALES S, ENTRYS EAlan
> WHERE S.IDENTRY = E.ID