Advertisement
rdfx

Untitled

May 24th, 2021
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. SELECT tmp.*, MAX(tmp.width+tmp.height+tmp.depth) AS dsum, MAX(tmp.weight) / (MAX(tmp.width)*MAX(tmp.height)*MAX(tmp.depth)) AS density
  2. FROM
  3. (SELECT eob.width, eob.height, eob.depth, eob.weight, COUNT(eob.id) pio, oi.product_id
  4. FROM external_order_box eob
  5. LEFT JOIN external_order eo ON eo.id = eob.external_order_id
  6. LEFT JOIN `order` o ON o.id = eo.erp_order_id
  7. LEFT JOIN order_item oi ON oi.order_id = o.id
  8. GROUP BY eo.id) AS tmp
  9. LEFT JOIN product p ON p.id = tmp.product_id
  10. WHERE pio = 1 AND (p.width IS NULL OR p.weight IS NULL OR p.depth IS NULL OR p.height IS null) GROUP BY product_id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement