1、通过SQL脚本获取凭证查询数据,再按客户汇总取金额
SELECT tlist.FNUMBER,FDEBIT,tlist.fperiod,fdate ,tlist.fyear,tlist.FNAME,1 type--,tlist.ORGFNAME
FROM
(SELECT CUS.FNUMBER,d.FNAME, t0.FDATE fdate, t0.FYEAR fyear, t0.FPERIOD fperiod,st01_L.FNAME AS ORGFNAME ,
t0.FVOUCHERGROUPID fvouchergroupid_id, t0.FVOUCHERGROUPNO fvouchergroupno,
t1.FEXPLANATION fexplanation, t1.FACCOUNTID faccountid_id, st12.FFlex6 AS FCUSTID,
t1.FCURRENCYID fcurrencyid_id, t1.FAMOUNTFOR famountfor,
t1.FDEBIT fdebit, t1.FCREDIT fcredit, t0.FCREATORID fcreatorid_id,
t0.FCHECKERID fcheckerid_id, t0.FPOSTERID fposterid_id, t0.FCASHIERID
fcashierid_id, t0.FATTACHMENTS fattachments, t0.FBILLNO fbillno,
t0.FSYSTEMID fsystemid_id, t0.FSOURCEBILLKEY fsourcebillkey_id,
t0.FDOCUMENTSTATUS fdocumentstatus, t0.FINVALID finvalid, t0.FBASECURRENCYID fbasecurrencyid_id,
st12.FOPCODE fdetailid_31, t0.FACCTORGID faccbookorgid, t0.FACCTORGID faccbookorgid_id,
t1.FEXCHANGERATETYPE fexchangeratetype, t0.FVOUCHERID fvoucherid, t1.FENTRYID t1_fentryid,
t1.FEntrySeq t1_fentryseq, ROW_NUMBER() OVER( ORDER BY st01_L.FNAME ASC, t0.FYEAR ASC,
t0.FPERIOD ASC, st02_L.FNAME ASC, t0.FVOUCHERGROUPNO ASC, t0.FVOUCHERID ASC, FENTRYSEQ ASC) fidentityid
FROM T_GL_VOUCHER t0
LEFT JOIN T_META_SUBSYSTEM_L d ON d.FID=t0.FSYSTEMID AND d.FLOCALEID=2052
LEFT OUTER JOIN T_GL_VOUCHERENTRY t1 ON t0.FVOUCHERID = t1.FVOUCHERID
LEFT OUTER JOIN T_BD_ACCOUNTBOOK_L st01_L ON (t0.FACCOUNTBOOKID = st01_L.FBOOKID AND st01_L.FLocaleId = 2052
) LEFT OUTER JOIN T_BD_VOUCHERGROUP_L st02_L ON (t0.FVOUCHERGROUPID = st02_L.FVCHGROUPID
AND st02_L.FLocaleId = 2052)
LEFT OUTER JOIN T_BD_FLEXITEMDETAILV st12 ON t1.FDETAILID = st12.FID
LEFT JOIN T_BD_CUSTOMER cus ON cus.FCUSTID=st12.FFlex6
INNER JOIN (SELECT DISTINCT FVOUCHERID FROM (
SELECT t0.FVOUCHERID fvoucherid FROM T_GL_VOUCHER t0
LEFT OUTER JOIN T_GL_VOUCHERENTRY t1 ON t0.FVOUCHERID = t1.FVOUCHERID
LEFT OUTER JOIN T_BD_ACCOUNTBOOK_L st01_L ON (t0.FACCOUNTBOOKID = st01_L.FBOOKID
AND st01_L.FLocaleId = 2052)
LEFT OUTER JOIN T_BD_ACCOUNT st11 ON t1.FACCOUNTID = st11.FACCTID
WHERE (((--(st01_L.FNAME = N'西迪技术股份有限公司账簿' AND t0.FYEAR >= 2024 and t0.FYEAR <=2024 ) AND
(t0.FYEAR >= 2024 AND t0.FYEAR <=2024) AND
(st11.FNUMBER = N'6401.01' OR st11.FNUMBER = N'6401.02')) AND
EXISTS (SELECT 1 FROM T_BD_ACCOUNTBOOK AB WHERE (AB.FFORBIDSTATUS = 'A'
AND AB.FBOOKID = t0.FACCOUNTBOOKID))) AND t0.FISADJUSTVOUCHER = '0')) tm)
vch ON vch.FVOUCHERID = t0.FVOUCHERID WHERE EXISTS (SELECT FVOUCHERID FROM
(SELECT t0.FVOUCHERID FROM T_GL_VOUCHER t0 WHERE t0.FACCTORGID IN (1))
txs WHERE txs.FVOUCHERID = t0.FVOUCHERID)) tlist
WHERE ((fidentityid >= 1) AND (fidentityid <= 10000))
AND (tlist.FNAME NOT LIKE '%销售%' )
--and tlist.FNAME != '总账'
AND tlist.fperiod>=1 AND tlist.fperiod<=1
--AND tlist.fdate>='2024-01-01' AND tlist.fdate<='2024-01-31'
-- AND tlist.FNUMBER='W1000-2750'
--GROUP BY tlist.FNUMBER--,tlist.FNAME
推荐阅读