--入库记录有多少天没有上传
select areabm,(select areaname from sun_jk_area b where b.bm=a.areabm ) as qymc,qydm,(select dmmc from sun_jk_jyqy c where c.dm=a.qydm and a.areabm=c.areabm) as qymc,max(updatetime) as maxupdate,datediff(dd,max(updatetime),getdate()) as ts from sun_jk_rkmx a group by areabm,qydm order by areabm,qydm
select areabm,(select areaname from sun_jk_area b where b.bm=a.areabm ) as qymc,qydm,(select dmmc from sun_jk_jyqy c where c.dm=a.qydm and a.areabm=c.areabm) as qymc,max(updatetime) as maxupdate,datediff(dd,max(updatetime),getdate()) as ts from sun_jk_ckmx a group by areabm,qydm order by areabm,qydm