Are you ever curious how many vouchers your AP team enters on a monthly and annual basis? This query will help you get those totals by the user who created the voucher. Just remember, since we are using APDOC, this is the count of vouchers. This does not take into account how many lines are on the voucher, which you would find by joining to APTRAN.
To display the username, you could join to the UserRec table in your SYS database.
declare @year varchar(4) = '2019' ;with cte as ( select d.batnbr, d.refnbr, d.doctype, d.perpost, d.crtd_user, d.crtd_datetime, d.vendid, d.origdocamt from dbo.apdoc d where d.doctype IN ('VO', 'AD', 'AC') AND YEAR(d.crtd_datetime) = @year ) select crtd_user,  as jan,  as feb,  as mar,  as apr,  as may,  as jun,  as jul,  as aug,  as sep,  as oct,  as nov,  as dec, SUM(+++++++++++) over (partition by crtd_user ) as total from ( select crtd_user, month(cte.crtd_datetime) AS mon, cte.doctype AS num from cte UNION ALL select 'TOTAL', month(cte.crtd_datetime), doctype from cte ) sub PIVOT (COUNT(num) for mon IN (,,,,,,,,,,,)) AS p order by crtd_user; go