Results 1 to 3 of 3

Thread: Calcule...

  1. #1
    Join Date
    Oct 2007
    Posts
    61

    Unanswered: Calcule...

    Hello..

    How I do this calcule in sql...

    valor / (1 + 0.098) ^ 10

  2. #2
    Join Date
    Aug 2005
    Posts
    140
    use pow function.

    select valor /pow((1+0.098),10) from tab2

    or

    select pow(valor/(1+0.098),10) from tab2

    depends what you want.

  3. #3
    Join Date
    Oct 2007
    Posts
    61
    Quote Originally Posted by stanislav.ondac
    use pow function.

    select valor /pow((1+0.098),10) from tab2

    or

    select pow(valor/(1+0.098),10) from tab2

    depends what you want.


    Omg..
    It so easy.

    I wrote the big function to work !

    CREATE FUNCTION nog_calc_tx_fin(p_cnd_pgto integer,p_valor decimal(10,4),p_taxa decimal(10,4)) RETURNS decimal(10,4)
    DEFINE v_prz_medio integer;
    DEFINE i integer;

    BEGIN

    select
    round(sum(b.qtd_dias_sd) / max(b.sequencia),2) as financeira into v_prz_medio
    from cond_pgto a, cond_pgto_item b
    where a.cod_cnd_pgto = b.cod_cnd_pgto and a.cod_cnd_pgto = p_cnd_Pgto;
    let i=1;

    while i <= v_prz_medio
    let p_valor = p_valor - (p_valor * p_taxa / 100);
    let i = i + 1;
    end while

    return p_valor;

    END
    END FUNCTION


    Anyways Thanks. I`ll use pow in the next time.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •