Subject | Re: {Disarmed} Re: [firebird-support] How do I figure what percentage one value is of another value inside a stored procedure? |
---|---|
Author | Iwan Cahyadi Sugeng |
Post date | 2011-08-04T16:12:54Z |
Try this, i think this is what he meant:
SELECT CS.ACCT_ID,
CS.CASE_ID,
CSD.ITEM_DESC,
CSD.ORIG_BAL_DUE,
CSD.SETTLEMENT_AMOUNT,
Case when CSD.ORIG_BAL_DUE > 0 then CSD.SETTLEMENT_AMOUNT /
CSD.ORIG_BAL_DUE else 0 end * 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
SELECT CS.ACCT_ID,
CS.CASE_ID,
CSD.ITEM_DESC,
CSD.ORIG_BAL_DUE,
CSD.SETTLEMENT_AMOUNT,
Case when CSD.ORIG_BAL_DUE > 0 then CSD.SETTLEMENT_AMOUNT /
CSD.ORIG_BAL_DUE else 0 end * 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
On Thu, Aug 4, 2011 at 10:45 PM, SoftTech <miket@...> wrote:
> **
>
>
> 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
>
> --
Iwan Cahyadi Sugeng
[Non-text portions of this message have been removed]