select budget_date,department_name,a.subject_name_2 as subject_name
from "L2"."subject_budget_marketing_rd_detail_new" a
where department_type='rd'
and budget_type='存里'
${if(find('%财务部%',GETUSERDEPARTMENTS())>0 && Fine_role="预算管控", "and department_name in ('"+GETUSERDEPARTMENTS()+"')","")}
group by budget_date,department_name,subject_name_2,subject_no
order by budget_date asc,department_name asc,subject_name_2 asc