Gecikme Ödeme Hesapla_SQL
--ort.gec.= ((ödeme t.1- vade t.1)*tutar1)+((ödeme t.2- vade t.2)*tutar2)+ .../ --toplam tutar DECLARE @vadetar datetime set @vadetar='20111001' DECLARE @odemetar1 datetime DECLARE @odemetar2 datetime DECLARE @odemetar3 datetime DECLARE @odemetar4 datetime set @odemetar1='20110811' set @odemetar2='20110926' set @odemetar3='20111016' set @odemetar4='20111130' declare @odemetutar1 int declare @odemetutar2 int declare @odemetutar3 int declare @odemetutar4 int set @odemetutar1=1000 set @odemetutar2=3000 set @odemetutar3=2500 set @odemetutar4=3500 Select SUM(DATEDIFF(d,@odemetar1,@vadetar)*@odemetutar1+ DATEDIFF(d,@odemetar2,@vadetar)*@odemetutar2+ DATEDIFF(d,@odemetar3,@vadetar)*@odemetutar3+ DATEDIFF(d,@odemetar4,@vadetar)*@odemetutar4)/SUM(@odemetutar1+@odemetutar2+@odemetutar3+@odemetutar4)
0 Yorum