Advertisement
zotov-vs

Untitled

Nov 9th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.64 KB | None | 0 0
  1. SELECT sc.agency_contract -- , c.is_agent
  2. , SUM(opn.in_stock * pp.products_purchase_price)
  3. FROM orders_products_new AS opn
  4. JOIN categories AS c ON c.categories_id = opn.products_categories_id
  5. JOIN products_prices AS pp ON pp.products_attributes_id = opn.products_attributes_id
  6. JOIN orders AS o ON o.orders_id= opn.orders_id
  7. LEFT JOIN suppliers_contracts AS sc ON sc.suppliers_id = c.suppliers_contracts_id
  8. WHERE opn.is_deleted = 0 AND c.date_end BETWEEN '2015-10-01' AND '2015-10-31 23:59:29'
  9.  
  10. -- AND sc.agency_contract = 'Y'
  11.  
  12. -- and c.is_agent = 1
  13. AND o.orders_status = 6 AND opn.is_return = 0
  14. GROUP BY sc.agency_contract
  15. -- , c.is_agent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement