Mikro programlarında, stokların son giriş fiyatlarını ana döviz ve orjinal döviz detayında veren sorgu.

 

 

 

SELECT TOP 100 PERCENT 
  sto_kod AS [Kodu],
  sto_isim AS [İsmi],
  sth_miktar AS [Son Giriş Miktar],
  ISNULL(STH_NET_DEGER_ANA/sth_miktar,0.0) AS [Son Giriş Birim Fiyatı Ana],
  ISNULL(STH_NET_DEGER_ANA,0.0) AS [Son Giriş Tutarı Ana],
  ISNULL(STH_NET_DEGER_CARI_ORJ/sth_miktar,0.0) AS [Son Giriş Birim Fiyatı Orj],
  ISNULL(STH_NET_DEGER_CARI_ORJ,0.0) AS [Son Giriş Tutarı Orj],
  STH_HAR_DOVIZ_SEMBOLU AS [Son Giriş Döviz Cinsi]
FROM STOKLAR WITH (NOLOCK)
LEFT OUTER JOIN STOK_HAREKETLERI_VIEW_WITH_INDEX_02 H WITH (NOLOCK) ON 
(H.sth_Guid=(SELECT TOP 1 K.sth_Guid 
        FROM STOK_HAREKETLERI K WITH (NOLOCK) 
        WHERE K.sth_stok_kod=H.sth_stok_kod AND
            K.sth_evraktip IN (3,13) AND
            K.sth_cins NOT IN (9,15)
        ORDER BY sth_tarih DESC, sth_create_date DESC))
ORDER BY sto_kod
Share This