select distinct to_char(iv.due_date, 'YYYY') as iv_year from iv_invoices iv, acs_objects o where iv.due_date > now() - '$last_years years' :: interval and iv.organization_id = :organization_id and iv.recipient_id = o.object_id [template::list::filter_where_clauses -and -name iv_years] select sum(total_amount) from iv_invoices where to_char(due_date, 'YYYY') = :iv_year and organization_id = :organization_id select count(invoice_id) from iv_invoices where to_char(due_date, 'YYYY') = :iv_year and organization_id = :organization_id