日期:2014-05-17  浏览次数:20679 次

oracle sql 语句优化

SELECT
     t.aoi_name,
     ( SELECT count(p.per_id) FROM d_person_info p, m_user_info u WHERE u.aoi_id = t.aoi_id and u.user_id = p.input_user and p.valid = '1' and p.input_date > to_date('2010-10-10','yyyy-mm-dd') and p.input_date < to_date('2012-10-10','yyyy-mm-dd')+1 ) v_person,
     ( SELECT count(p.per_id) FROM d_body_check_info p, m_user_info u WHERE u.aoi_id = t.aoi_id and u.user_id = p.input_user and p.valid = '1' and p.BCI_DATE > to_date('2010-10-10','yyyy-mm-dd') and p.BCI_DATE < to_date('2012-10-10','yyyy-mm-dd')+1 ) v_bodycheck,
     ( SELECT count(p.per_id) FROM D_NEWBORN_HOME_VISIT p, m_user_info u WHERE u.aoi_id = t.aoi_id and u.user_id = p.input_user and p.valid = '1' and p.new_visitDate > to_date('2010-10-10','yyyy-mm-dd') and p.new_visitDate < to_date('2012-10-10','yyyy-mm-dd')+1 ) v_born,
     ( SELECT count(p.per_id) FROM D_oneChild_health_exam p, m_user_info u WHERE u.aoi_id = t.aoi_id and u.user_id = p.input_user and p.valid = '1' and p.OC_visitDate > to_date('2010-10-10','yyyy-mm-dd') and p.OC_visitDate < to_date('2012-10-10','yyyy-mm-dd')+1 ) v_one,
     ( SELECT count(p.per_id) FROM D_twoChild_health_exam p, m_user_info u WHERE u.aoi_id = t.aoi_id and u.user_id = p.input_user and p.valid = '1' and p.TWC_visitDate > to_date('2010-10-10','yyyy-mm-dd') and p.TWC_visitDate < to_date('2012-10-10','yyyy-mm-dd')+1 ) v_two,
     ( SELECT count(p.per_id) FROM D_CHILD_HEALTH_EXAM p, m_user_info u WHERE u.aoi_id = t.aoi_id and u.user_id = p.input_user and p.valid = '1' and p.CHE_DATE > to_date('2010-10-10','yyyy-mm-dd') and p.CHE_DATE < to_date('2012-10-10','yyyy-mm-dd')+1 ) v_six,
     ( SELECT count(p.per_id) FROM D_FIRST_follow_service p, m_user_info u WHERE u.aoi_id = t.aoi_id and u.user_id = p.input_user and p.valid = '1' and p.ffs_fillDate > to_date('2010-10-10','yyyy-mm-dd') and p.ffs_fillDate < to_date('2012-10-10','yyyy-mm-dd')+1 ) v_first,
     ( SELECT count(p.per_id) FROM D_follow_service_info p, m_user_info u WHERE u.aoi_id = t.aoi_id and u.user_id = p.input_user and p.valid = '1' and p.fts_wVisDate > to_date('2010-10-10','yyyy-mm-dd') and p.fts_wVisDate < to_date('2012-10-10','yyyy-mm-dd')+1 ) v_second,
     ( SELECT count(p.per_id) FROM D_Postpartum_visits p, m_user_info u WHERE u.aoi_id = t.aoi_id and u.user_id = p.input_user and p.valid = '1' and p.pv_f