select 

bpc.name,
bpsc.name,
con.no_old_style,
con.year,
ps.reporting_period_start,
ps.reporting_period_end,
org.name,
dd.patient_name,
dd.cra_person_code,
dd.artificial_code,
ps.id,
dd.approved_amount,
dd.requested_amount,
dd.id


from
BUDGET_PROGRAM bp INNER JOIN
BUDGET_PROGRAM_COMPONENT bpc ON bp.ID=bpc.BUDGET_PROGRAM_ID INNER JOIN
BUDGET_PROGRAM_SUBCOMPONENT bpsc ON bpsc.BUDGET_PROGRAM_COMPONENT_ID=bpc.ID INNER JOIN
[CONTRACT] con ON con.BUDGET_PROGRAM_SUBCOMPONENT_ID=bpsc.ID INNER JOIN
ORGANIZATION org ON con.ORGANIZATION_ID=org.id INNER JOIN
PROVIDED_SERVICE ps ON ps.CONTRACT_ID=con.ID INNER JOIN
DOC doc ON ps.ID=doc.PROVIDED_SERVICE_ID INNER JOIN
DOC_DETAIL dd ON (dd.DOC_ID=doc.ID) inner join
DOC_DETAIL_ERROR dde on dd.id=dde.DOC_DETAIL_ID
left join FINANCING_PLAN_ITEM fpi on fpi.ID=dd.FINANCING_PLAN_ITEM_ID

where DOC_DETAIL_ERROR_TYPE_ID=106 

and month(ps.reporting_period_start) >5 and year(ps.reporting_period_start)=2014

order by ps.reporting_period_start