a guest Jul 22nd, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT DISTINCT o."order_sid"
  2. FROM "order"."order" o
  3. INNER JOIN "order".item i ON (i.order_sid = o.order_sid)
  4. INNER JOIN "product"."product" p ON (p.product_sid = i.product_sid AND is_gift is true)
  5. INNER JOIN "order".status s ON (s.order_sid = o.order_sid AND s.status = 'completed')
  6. INNER JOIN "order".status s2 ON (s2.order_sid = o.order_sid AND s2.status_sid <> s.status_sid AND s2.status = 'completed')
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