これは機能するはずです:
select sum(amount) sum,
(
STUFF((
SELECT DISTINCT ',' + CAST(a.id AS VARCHAR(100))
FROM t_vouchers a
WHERE a.isactive = 1
FOR XML PATH('')
),1,1,'')
) ids
from t_vouchers
where isactive = 1
これが