what were the three most frequently prescribed drugs for patients who were previously prescribed with aripiprazole during the same hospital encounter since 4 years ago?
select t3.drug from ( select t2.drug, dense_rank() over ( order by count(*) desc ) as c1 from ( select admissions.subject_id, prescriptions.startdate, admissions.hadm_id from prescriptions join admissions on prescriptions.hadm_id = admissions.hadm_id where prescriptions.drug = 'aripiprazole' and datetime(prescriptions.startdate) >= datetime(current_time,'-4 year') ) as t1 join ( select admissions.subject_id, prescriptions.drug, prescriptions.startdate, admissions.hadm_id from prescriptions join admissions on prescriptions.hadm_id = admissions.hadm_id where datetime(prescriptions.startdate) >= datetime(current_time,'-4 year') ) as t2 on t1.subject_id = t2.subject_id where t1.startdate < t2.startdate and t1.hadm_id = t2.hadm_id group by t2.drug ) as t3 where t3.c1 <= 3