2

I want to get order total of the month January 2019 for complete orders

I need to know tables related to this query, or if someone can share query that would be great.

  • order total, you mean the total number of orders for year 2019 or the total sum of amount of all the order for the specific month? – fmsthird Mar 26 at 9:57
  • I need sum amount – Muhammad Anas Mar 26 at 10:03
2

Your questions seems double meaning for me, so here I'll post my answer assuming:

You want to get the Total Numbers of order for the specific month, below query should work

SELECT count(entity_id) FROM sales_order where state='complete' and status='complete' and month(created_at) = '01' and year(created_at) = '2019';  

You want to get the total sum amount you can try this (This will filter only order that are completed):

SELECT sum(base_grand_total) FROM sales_order where state='complete' and status='complete' and month(created_at) = '01' and year(created_at) = '2019';
1

Here is query which will give you order total of completed order's for month jan 2019:

SELECT sum(base_grand_total) FROM  sales_order
WHERE created_at >='2018-12-31 23:59:59.000' AND created_at <= '2019-02-31 
23:59:59.000' AND status='complete'
  • Thanks Mohit, but it is showing warning that incorrect datetime format – Muhammad Anas Mar 26 at 10:03
  • Thanks for answer. +1 – Muhammad Anas Mar 26 at 10:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.