title: How to Optimise View?
body: <p>The following View returns result after very long time. How to optmise it for quick result ?</p>
  
  <pre><code>CREATE OR REPLACE VIEW v_e_soa
    AS
      SELECT substr(account_id,1,16) account_id,
             stmt_on_email,
             MIN(curr_no) curr_no,
             co_code,
             ( SELECT convert_to_date(MIN(date_time) )
               FROM ext_account_his_31122017 y
               WHERE y.stmt_on_email = x.stmt_on_email
                     AND   substr(y.account_id,1,16) = substr(x.account_id,1,16)
             ) date_time
      FROM ext_account_his_31122017 x
      WHERE stmt_on_email = 'YES'
      GROUP BY substr(account_id,1,16),
               stmt_on_email,
               co_code;
  </code></pre>