Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.60 KB | None | 0 0
  1. SELECT ROUND(SUM((IF(orders_products.products_quantity > 0,orders_products.products_quantity,0) + IFNULL(ops.products_quantity, 0)) * ROUND(final_price * ((100 - IFNULL(discount,0))/100)))) AS `total`
  2. FROM `orders` `o`
  3. LEFT JOIN `orders_products` ON `o`.`orders_id` = `orders_products`.`orders_id`
  4. LEFT JOIN `orders_products_sp` `ops` ON `orders_products`.`orders_products_id` = `ops`.`orders_products_id`
  5. LEFT JOIN `orders_spec_predl` ON `o`.`orders_id` = `orders_spec_predl`.`orders_id`
  6. WHERE (`customers_id`= 11663) AND (`date_purchased` >= '2013-07-01 00:00:00')  AND (`orders_status` IN (2, 3, 4, 5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement