Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. SELECT SUM(vxl_order_line.discount)
  2. FROM vxl.vxl_order
  3. JOIN vxl.vxl_order_line USING (outlet_id, vxl_order_id)
  4. JOIN vxl.applied_discount USING (outlet_id, vxl_order_id)
  5. JOIN vxl.discount USING (discount_id)
  6. WHERE order_ts >= '{cash_out_tstamp_start}'::timestamptz
  7. AND order_ts < '{cash_out_tstamp_end}'::timestamptz
  8. AND order_line_status NOT IN ('void', 'return')
  9. AND NOT training_data
  10. AND vxl_order.outlet_id = {outlet_id}
  11. AND discount > 0
  12. AND vxl_order_line.vxl_order_line_id = applied_discount.vxl_order_line_id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement