sthar_altbilgi.sql 870 B

1234567891011121314
  1. set @iscari := '@iscari@';
  2. set @stkod := '@stkod@';
  3. select sum(round(t.giris,3)) as giriþ,sum(round(t.cikis,3)) as çýkýþ,round((sum(giris)-sum(cikis)),2) as bakiye,
  4. sum(round(t.giristut,3)) as giriþ_tutar,sum(round(t.cikistut,3)) as çýkýþ_tutar,round((sum(giristut)-sum(cikistut)),2) as bakiye_tutar
  5. from(
  6. select
  7. stok_kodu,
  8. case when (ftip='C' and hedef=@iscari) or (ftip='G' and kaynak=@iscari) then miktar else 0 end as giris,
  9. case when ftip='C' and kaynak=@iscari or (ftip='G' and hedef=@iscari) then miktar else 0 end as cikis,
  10. case when (ftip='C' and hedef=@iscari) or (ftip='G' and kaynak=@iscari) then miktar*bf else 0 end as giristut,
  11. case when ftip='C' and kaynak=@iscari or (ftip='G' and hedef=@iscari) then miktar*bf else 0 end as cikistut
  12. from sthar where stok_kodu=@stkod and (hedef=@iscari or kaynak=@iscari)
  13. )as t
  14. group by t.stok_kodu