Subject Re: {Disarmed} Re: [firebird-support] How do I figure what percentage one value is of another value inside a stored procedure?
Author SoftTech
Greeting Marco,

I think you may be right on the division by zero. Not sure what you mean by
"use CASE to check before division".

Could you please elaborate.

Thanks,
Mike

----- Original Message -----
From: "marco bianchini" <informarco@...>
To: <firebird-support@yahoogroups.com>
Sent: Thursday, August 04, 2011 8:15 AM
Subject: Re: {Disarmed} Re: [firebird-support] How do I figure what
percentage one value is of another value inside a stored procedure?


> may be division by zero,
> use CASE to check before division, and return something else if A = 0
>
> 2011/8/4 SoftTech <miket@...>
>
>> **
>>
>>
>> Hmm, common math, who knew :>) And seems simple enough but returns an
>> error
>> "arithmetic exception, numeric overflow, or string truncation"
>>
>> Adding "((CSD.SETTLEMENT_AMOUNT / CSD.ORIG_BAL_DUE) * 100.00) AS
>> PERCENTAGE" to the SQL statement below creates the error.
>>
>> Both SETTLEMENT_AMOUNT and ORIG_BAL_DUE are defined as Numeric(15,2)
>>
>> SELECT CS.ACCT_ID,
>> CS.CASE_ID,
>> CSD.ITEM_DESC,
>> CSD.ORIG_BAL_DUE,
>> CSD.SETTLEMENT_AMOUNT,
>> ((CSD.SETTLEMENT_AMOUNT / CSD.ORIG_BAL_DUE) * 100.00) AS PERCENTAGE
>> FROM CASE_SETTLEMENT_DETAIL CSD
>> JOIN CASE_SETTLEMENT CS ON CS.SETTLEMENT_ID = CSD.SETTLEMENT_ID
>> AND CS.SETTLEMENT_SEQ_NO = CSD.SETTLEMENT_SEQ_NO
>> WHERE CS.ACCT_ID = :ACCT_ID
>> AND CS.CASE_ID = :CASE_ID
>> AND CS.STATUS_CODE = 'A'
>> ORDER BY CSD.SEQ_NO
>>
>> Any ideas what I may have done wrong?
>>
>> Thanks,
>> Mike
>>
>> ----- Original Message -----
>> From: Thomas Steinmaurer
>> To: firebird-support@yahoogroups.com
>> Sent: Thursday, August 04, 2011 7:53 AM
>> Subject: {Disarmed} Re: [firebird-support] How do I figure what
>> percentage
>> one value is of another value inside a stored procedure?
>>
>> > Firebird 1.5.3
>> >
>> > Is it possible to return a percentage of the following within a stored
>> > procedure?
>> >
>> > Value A = $1000.00
>> > Value B = $600.00
>> >
>> > Result C = 60%
>>
>> (B / A) * 100
>>
>> ;-)
>>
>> --
>> With regards,
>>
>> Thomas Steinmaurer
>> Upscene Productions
>> http://www.upscene.com
>> http://blog.upscene.com/thomas/
>>
>> Download LogManager Series, FB TraceManager today!
>> Continuous Database Monitoring Solutions supporting
>> Firebird, InterBase, Advantage Database, MS SQL Server
>> and NexusDB!
>>
>> --
>> MailScanner Virus/Spam/Malware: PASS (GZ)
>>
>> [Non-text portions of this message have been removed]
>>
>>
>>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Yahoo! Groups Links
>
>
>
>
> --
> MailScanner Virus/Spam/Malware: PASS (GZ)
>
>