select * into
where 1=1 $(多值-合并报表-账套名称) $(多值-凭证号)
select a.*,b.cashid,b.cashname,
case when a.isbook=0 then '已记账' else '未记账' end as 是否记账,
case when a.ccodefx=1 then '借' else '贷' end as 科目方向
from
left join CO_JC_ERP_CashTable as b
on a.dbtype=b.dbtype and a.dbName=b.dbname and a.iyear=b.iyear and a.iperiod=b.iperiod
and a.billnum=b.billnum and a.rownum=b.rownum
and isnull(a.isignseq,'')=isnull(b.isignseq,'') and a.isbook=b.isbook
where a.iyear*12+a.iperiod>=left('$(日期-合并报表-起始年月)',4)*12+
right('$(日期-合并报表-起始年月)',2)
and a.iyear*12+a.iperiod<=left('$(日期-合并报表-截止年月)',4)*12+
right('$(日期-合并报表-截止年月)',2)
and a.iperiod in(1,2,3,4,5,6,7,8,9,10,11,12)
order by a.accidname,a.billdate,a.billnum,a.rownum
drop table