SELECT ap.apnum AS 'Vendor #', apname AS 'Vendor Name', csd.apaddid AS 'Address #', apaddr.appynm AS 'Payee Name', COUNT(cknum) AS '# Checks', SUM(ckamt) AS '$ Checks', nvo.numvoucher AS '# Vouchers', nvo.dolvoucher AS '$ Vouchers' FROM ap INNER JOIN csd ON ap.apnum = csd.apnum INNER JOIN apaddr ON csd.apaddid = apaddr.apaddid AND csd.apnum = apaddr.apnum LEFT OUTER JOIN ( SELECT apvo.apnum, apvo.apaddid, COUNT(vo_id) AS numvoucher, SUM(voamt) AS dolvoucher FROM apvo WHERE YEAR(votrdt)='2009' GROUP BY apvo.apnum,apvo.apaddid) AS nvo ON csd.apnum=nvo.apnum AND csd.apaddid = nvo.apaddid WHERE YEAR(ckdate) = '2009' AND (voiddt IS NULL OR ckstat <> 'V') GROUP BY ap.apnum,apname,csd.apaddid,apaddr.appynm,numvoucher, dolvoucher HAVING SUM(ckamt) > 0 ORDER BY SUM(ckamt) DESC
Tuesday, January 26, 2010
Check & Voucher Totals by Vendor
It is always interesting to look at year-end stats, and this query is no exception. This will show you the number and dollar amount of vouchers and checks by vendor that your Accounts Payable department processed in a given year, with the focus being on value of checks. Note, as it is currently written, this will not return any vendors with vouchers but no checks.
Labels:
accounts payable,
ap,
enterprise,
fms,
sql,
vendor,
voucher
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment