tarihli_bakiye.sql 572 B

1234567891011
  1. set @iscari := '12';
  2. select t.kod,t.isim,
  3. round(sum(giris-cikis),2) as bakiye,t.fiyat,round((sum(giris-cikis)*t.fiyat),2) as btut from(
  4. select b.stok_kodu as kod,a.stok_adi as isim,bf as fiyat,
  5. case when (ftip='C' and hedef=@iscari) or (ftip='G' and kaynak=@iscari) then b.miktar else 0 end as giris,
  6. case when ftip='C' and kaynak=@iscari or (ftip='G' and hedef=@iscari) then b.miktar else 0 end as cikis
  7. from sthar as b
  8. inner join tblstsabit as a on a.stok_kodu=b.stok_kodu
  9. where (hedef=@iscari or kaynak=@iscari) and tarih<'2015-01-12'
  10. )as t
  11. group by kod