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.

Muhammad Hasham
8,75211 gold badges53 silver badges105 bronze badges
asked Mar 26, 2019 at 9:24
2
  • 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? Commented Mar 26, 2019 at 9:57
  • I need sum amount Commented Mar 26, 2019 at 10:03

2 Answers 2

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';
answered Mar 26, 2019 at 10:04
1
  • 1
    It worked. Thanks Commented Mar 26, 2019 at 10:10
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'
answered Mar 26, 2019 at 9:54
2
  • Thanks Mohit, but it is showing warning that incorrect datetime format Commented Mar 26, 2019 at 10:03
  • Thanks for answer. +1 Commented Mar 26, 2019 at 10:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.