title: How to filter the customize query?
body: <p>How to filter the completed_date in following query?</p>
  
  <pre><code>SELECT `wp_woocommerce_order_items`.order_id,
  MAX(CASE WHEN `wp_postmeta`.`meta_key` = '_order_currency' THEN `wp_postmeta`.`meta_value`  END) AS order_currency,
  MAX(CASE WHEN `wp_postmeta`.`meta_key` = '_order_total' THEN `wp_postmeta`.`meta_value`  END) AS order_total,
  MAX(CASE WHEN `wp_postmeta`.`meta_key` = '_completed_date' THEN `wp_postmeta`.`meta_value`  END) AS completed_date
  FROM wp_posts
  LEFT JOIN `wp_woocommerce_order_items` ON `wp_posts`.`ID`= `wp_woocommerce_order_items`.`order_id` AND order_item_type = 'line_item'
  LEFT JOIN `wp_postmeta` ON `wp_postmeta`.`post_id` = `wp_posts`.`ID`
  LEFT JOIN `wp_woocommerce_order_itemmeta` ON `wp_woocommerce_order_itemmeta`.order_item_id = `wp_woocommerce_order_items`.order_item_id
  WHERE `wp_posts`.`post_status` = 'wc-completed'
  GROUP BY `wp_woocommerce_order_items`.order_item_id
  ORDER BY completed_date DESC
  </code></pre>
  
  <p>update</p>
  
  <p>before filter</p>
  
  <pre><code>order_id,order_currency,order_total,completed_date
  5338,USD,299.00,"2017-03-09 10:07:00"
  5336,USD,15.00,"2017-03-04 03:54:41"
  5335,USD,299.00,"2017-03-03 17:34:19"
  5334,USD,15.00,"2017-03-01 12:30:54"
  5333,USD,299.00,"2017-02-28 17:03:05"
  5332,USD,15.00,"2017-02-25 12:04:10"
  5330,USD,15.00,"2017-02-25 01:50:07"
  5329,USD,129.00,"2017-02-25 01:48:36"
  5328,USD,299.00,"2017-02-23 23:55:36"
  5327,USD,39.00,"2017-02-23 16:06:00"
  5326,USD,299.00,"2017-02-21 19:33:43"
  5325,USD,15.00,"2017-02-19 15:35:34"
  </code></pre>
  
  <p>after filter between 2017-02-25 and 2017-02-28</p>
  
  <pre><code>order_id,order_currency,order_total,completed_date
  5333,USD,299.00,"2017-02-28 17:03:05"
  5332,USD,15.00,"2017-02-25 12:04:10"
  5330,USD,15.00,"2017-02-25 01:50:07"
  5329,USD,129.00,"2017-02-25 01:48:36"
  </code></pre>
  
  <p>And another question is "How could I modify this query to get same result?" because it is taking more than 5 sec.</p>