首页 > 其他分享 >查询日期用会计期间比制单日期取年月快

查询日期用会计期间比制单日期取年月快

时间:2022-08-18 14:33:46浏览次数:58  
标签:cust dbo 账套 dep 日期 取年 制单 ga u8

select
ga.iperiod as 月,ga.iyear as 年,
(select case when dep.cDepCode is null then dep1.cDepCode
else dep.cDepCode end) as 部门编码,
(select case when dep.cDepName is null then dep1.cDepName
else dep.cDepName end) as 部门,
cusc1.cCCCode as 省份编码,cusc1.cCCName as 省份,
cusc.cCCCode as 客户分类编码,cusc.cCCName as 客户分类,cust.cCusCode as 客户编码,cust.cCusName as 客户名称,
sum(case when ga.ccode in ('某某科目编码') then ga.mc end) as 某某科目
from u8.UFDATA_账套文件夹.dbo.GL_accvouch ga
left join u8.UFDATA_账套文件夹.dbo.customer cust on ga.ccus_id = cust.cCusCode
left join u8.UFDATA_账套文件夹.dbo.CustomerClass cusc on cust.cCCCode = cusc.cCCCode
left join u8.UFDATA_账套文件夹.dbo.code cod on cod.ccode = ga.ccode and cod.iyear = ga.iyear
left join u8.UFDATA_账套文件夹.dbo.CustomerClass cusc1 on left(cusc.cCCCode,2) = cusc1.cCCCode
left join u8.UFDATA_账套文件夹.dbo.DistrictClass disp on cust.cDCCode=disp.cDCCode
left join u8.UFDATA_账套文件夹.dbo.Department dep on cust.cCusDepart = dep.cDepCode
left join u8.UFDATA_账套文件夹.dbo.Department dep1 on ga.cdept_id = dep1.cDepCode
where (case when dep.cDepCode is null then dep1.cDepCode else dep.cDepCode end) in ('某某部门')

group by ga.iperiod,ga.iyear,cust.cCusCode,cusc.cCCCode,cusc.cCCName,cust.cCusName,cusc1.cCCCode,cusc1.cCCName,
case when dep.cDepCode is null then dep1.cDepCode else dep.cDepCode end,
case when dep.cDepName is null then dep1.cDepName else dep.cDepName end

 

换成year(dbill_date)和month(dbill_date)就慢如龟爬,不知道是不是哪里触发了全表扫描

标签:cust,dbo,账套,dep,日期,取年,制单,ga,u8
From: https://www.cnblogs.com/ccodename/p/16598603.html

相关文章