daily pastebin goal
56%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT
  2.                     item.sku as sku,
  3.                     item.name as name,
  4.                     COUNT(sale_item.id) as item_count,
  5.                     SUM(sale_item.price) as item_price_total,
  6.                     refund
  7.                 FROM
  8.                     {{sale_item}} as sale_item,    
  9.                     {{item}} as item,
  10.                     {{sale_instance}} as instance
  11.                     LEFT JOIN
  12.                         (SELECT
  13.                             COUNT(sale_item_status) as refund
  14.                         FROM
  15.                             {{sale_item}} as sale_item,
  16.                             {{item}} as item,
  17.                             {{sale_instance}} as instance
  18.                         WHERE
  19.                             item_id = item.id
  20.                             AND sale_id = instance.id
  21.                             AND sale_item_status = "refund"
  22.                             AND end_time BETWEEN "2011-09-06 16:45:24" AND "2012-09-08 16:45:24"
  23.                         GROUP BY item_id) as refund ON sale_item.item_id = item.id                 
  24.                 WHERE
  25.                     item_id = item.id
  26.                     AND sale_id = instance.id
  27.                     AND end_time BETWEEN "2011-09-06 16:45:24" AND "2012-09-08 16:45:24"
  28.                 GROUP BY item_id
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top