通过以下内容,我们通过这些条件获取列表。
我们的客户最晚付款日期是种植者,然后是输入的日期,并且只有选定的付款类型(现金、支票、信用卡等)
亲爱的 Gordon Linof 以前帮助我使用Row_number
部分和查询作品。
但是今天我们遇到了一个奇怪的情况。当我们查看时,查询没有在 list wand 中找到客户,我们发现该客户没有向我们发送付款。所以查询没有找到最后的付款记录,因此没有显示在列表中。
现在的问题...如果客户之前没有付款,我该如何更改此查询。
SELECT t.cari_kod
AS Cari_Kod,
t.cari_unvan1
AS Unvan,
mikrodb_v14_dekor2011.dbo.Fn_carihesapanadovizbakiye('', 0, t.cari_kod, '', '', NULL, NULL, NULL, 0) AS BakiyeTutar,
t.cari_temsilci_kodu
AS TmsKodu,
cpt.cari_per_adi
AS Adi,
cpt.cari_per_soyadi
AS Soyadi,
t.cha_tarihi
AS Tarih,
t.cha_meblag
AS Tutar,
Datediff(day, t.cha_tarihi, Getdate())
AS GunFarki,
t.cari_bolge_kodu
AS Bolge
FROM (SELECT cr.*,
chh.*,
Row_number()
OVER (
partition BY chh.cha_kod
ORDER BY chh.cha_recno DESC) AS seqnum
FROM mikrodb_v14_dekor2011.dbo.cari_hesaplar cr
LEFT JOIN mikrodb_v14_dekor2011.dbo.cari_hesap_hareketleri chh
ON chh.cha_kod = cr.cari_kod
WHERE 1 = 1
AND chh.cha_tip = 1
--and chh.cha_cinsi in (0,1,2,3,4,5,19,20)
AND chh.cha_evrak_tip IN ( 1, 2, 3, 4,
34, 65, 67, 98 )
AND chh.cha_tarihi > '20130101') t
LEFT OUTER JOIN mikrodb_v14_dekor2011.dbo.cari_personel_tanimlari cpt
ON ( t.cari_temsilci_kodu = cpt.cari_per_kod )
WHERE t.seqnum = 1
AND t.cari_temsilci_kodu IN ( 'PKAD01', 'PKMS04' )
ORDER BY
mikrodb_v14_dekor2011.dbo.Fn_carihesapanadovizbakiye('', 0, cari_kod, '', '', NULL, NULL, NULL, 0) DESC