mahmudkuet

Relisted item report

Jun 23rd, 2018
139
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT SUM(total_sale) FROM (
  2.  
  3. SELECT sales.relisted_item_id, COUNT(*) AS total_sale FROM
  4.     (SELECT ended_items.relisted_item_id, transaction_created_at FROM
  5.     (SELECT relisted_item_id, is_relisted, trial FROM ended_items WHERE is_relisted=1 AND trial<>0 AND store_id=2) ended_items JOIN transactions ON ended_items.relisted_item_id = transactions.item_id) sales  
  6.     /*where date(transaction_created_at)='2018-06-17'*/
  7.     GROUP BY sales.relisted_item_id HAVING total_sale > 0
  8.    
  9. ) t1
RAW Paste Data