[这是我用来获取帐龄桶的查询,很多帐户属于正确的桶。但很少有帐户甚至没有落入任何账龄账单。
ArBal现场实验室应落在正确的老化桶支架之下。
,case WHEN DATEDIFF(day,COALESCE(bv.DischargeDateTime,bv.ServiceDateTime,bb.CutoffDateTime,bv.AdmitDateTime),GETDAT E()) > 90 and DATEDIFF(day,COALESCE(bv.DischargeDateTime,bv.ServiceDateTime,bb.CutoffDateTime,bv.AdmitDateTime),GETDAT E()) < 121 and bvfd.BarStatus ='FB' then isnull(bvfd.Balance,'0') ELSE '' END 'AR_91_120'
,case WHEN DATEDIFF(day,COALESCE(bv.DischargeDateTime,bv.ServiceDateTime,bb.CutoffDateTime,bv.AdmitDateTime),GETDATE()) > 120 and DATEDIFF(day,COALESCE(bv.DischargeDateTime,bv.ServiceDateTime,bb.CutoffDateTime,bv.AdmitDateTime),GETDATE()) < 151 and bvfd.BarStatus ='FB' then isnull(bvfd.Balance,'0') ELSE '' END 'AR_121_150'
,case WHEN DATEDIFF(day,COALESCE(bv.DischargeDateTime,bv.ServiceDateTime,bb.CutoffDateTime,bv.AdmitDateTime),GETDATE()) > 150 and DATEDIFF(day,COALESCE(bv.DischargeDateTime,bv.ServiceDateTime,bb.CutoffDateTime,bv.AdmitDateTime),GETDATE()) < 181 and bvfd.BarStatus ='FB' then isnull(bvfd.Balance,'0') ELSE '' END 'AR_151_180'
,case WHEN DATEDIFF(day,COALESCE(bv.DischargeDateTime,bv.ServiceDateTime,bb.CutoffDateTime,bv.AdmitDateTime),GETDATE()) > 181 and bvfd.BarStatus ='FB' then isnull(bvfd.Balance,'0') ELSE '' END 'AR_181_Plus'
AcctNumb Pri_FinCl Receivable_Status Charges Payments Adjustments Refunds 1 MCLgr FB 8139 266.76 7872.24 0 2 MCgd FB 1505 329.67 1247.61 0
4 MCw FB 64391 13362.29 49664.71 0
字段的继续
**ArBal** UrBal AccountBalance AdmitDate DischargeDate 0 0 0 6/22/2019 6/23/2019 -72.28 0 -72.28 6/22/2019 6/23/2019 4077.12 0 4077.12 6/26/2019 6/26/2019 1364 0 1364 6/22/2019 6/26/2019
字段的继续
UR_0_30 UR_Greater_30 AR_0_30 AR_31_60 AR_61_90 AR_91_120 AR_121_150 AR_151_180 AR_181_Plus 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -72.28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
但是我应该在相应的账龄时段中获得ARBal字段..但是我确实看到帐户3和4的全零。请帮助我
将整个查询发布在这里
[这是我用来获取帐龄桶的查询,很多帐户属于正确的桶。但很少有账户甚至没有落入任何账龄账单。 ArBal现场实验室...
查看您的比较:
您可以为此使用BETWEEN
。