let's count the number of times patient 20165 has had a other blood products intake until 07/2102.
select count(*) from inputevents_cv where inputevents_cv.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20165 ) ) and inputevents_cv.itemid in ( select d_items.itemid from d_items where d_items.label = 'other blood products' and d_items.linksto = 'inputevents_cv' ) and strftime('%y-%m',inputevents_cv.charttime) <= '2102-07'