Subject Know nothing - please help
Author
I have a query like this:

select
    artikli.a_sif,
    v1.v_txt,
    v2.v_txt,
    coalesce(sum(magkol.k_total),0) total,
    coalesce(sum(magkol.k_nabcen * magkol.k_total),0) vrednost,
    coalesce(sum(magkol.k_nabcen * magkol.k_total),0)/ coalesce(sum(magkol.k_total),1) nc,
    coalesce(sum(izlaz.i_kol),0) P_kom
from artikli
   left outer join izlaz on (artikli.a_id = izlaz.i_id)
   left outer join magkol on (artikli.a_id = magkol.k_art) and magkol.k_mag>0
   right outer join vrste v1 on v1.v_id=artikli.a_vrs
   left outer join vrste v2 on v2.v_id=v1.v_nad
   where artikli.a_sif='R3728'
group by 1,2,3


everyting works OK, except that last sum() :


    coalesce(sum(izlaz.i_kol),0) P_kom

 

It gives me sum result muliplied with number of occurences of that article ID in magkol table.

When I put out parts with magkol table, I get corect result.


Can someone help me.


Regards,


Zoran