对其SQL进行优化

 /* Formatted on 2008/09/23 09:27 (Formatter Plus v4.8.8) */
SELECT   a.counsel_id, a.mem_id, a.mem_name, a.status, a.email, a.recv_type,
         (CASE a.title
             WHEN '-'
                THEN (SELECT counsel_cate_name
                        FROM cm_counsel_cate
                       WHERE counsel_cate_id = a.counsel_cate_id)
             ELSE a.title
          END
         ) title,
         SUBSTR (a.regist_dtm, 1, 8) write_date,
         TO_DATE (SUBSTR (a.regist_dtm, 1, 8), 'yy/MM/dd') fmt_write_date,
         (SELECT plant_name
            FROM user_sm_plant@cmsdb
           WHERE plant = b.shop_cd) AS plant_name,
         (SELECT counsel_cate_name
            FROM cm_counsel_cate
           WHERE counsel_cate_id = a.counsel_cate_id) AS counsel_cate_name
    FROM cm_counsel a,
         (SELECT *
            FROM cm_counsel_request
           WHERE status IN ('0', '1')) b
   WHERE a.counsel_id = b.counsel_id(+)
     AND (   a.counsel_cate_id IN (
                       SELECT counsel_cate_id
                         FROM cm_counsel_cate
                        WHERE upper_csl_cate_id BETWEEN '1000000' AND '1999999')
          OR a.counsel_cate_id BETWEEN '1000000' AND '1999999'
         )
     AND b.shop_cd = 'S259'
ORDER BY a.counsel_id DESC

你可能感兴趣的:(数据库,sql,date,优化,user)