Jump to content

Export sales of certain date through SQL statement


Recommended Posts

Hi,

 

I would like to know if someone has a query to export the sales at level item-attributte of the orders that are shipped (4) or delivered (5) between two dates. I have checked that the dates column are datetime and it makes the process harder.

 

I have the following statement without the date range and does not work

 

select ord.product_reference Reference, ord.product_name Name, sum(ord.product_quantity) Quantity

from pr_order_detail ord, pr_orders or

where or.id_order = ord.id_order

and or.current_state in (4,5)

and or.date_add between ("first day and last day of the month" how to do that?)

 

I will appreciate your help. Thanks.

 

Fernando

Link to comment
Share on other sites

  • 2 months later...

or is a keyword.

 

Try

select ord.product_reference Reference, ord.product_name Name, sum(ord.product_quantity) Quantity
from pr_order_detail ord, pr_orders o
where o.id_order = ord.id_order
and o.current_state in (4,5)
and o.date_add between '2013-01-01' and '2013-12-31'

Link to comment
Share on other sites

or is a keyword.

 

Try

select ord.product_reference Reference, ord.product_name Name, sum(ord.product_quantity) Quantity

from pr_order_detail ord, pr_orders o

where o.id_order = ord.id_order

and o.current_state in (4,5)

and o.date_add between '2013-01-01' and '2013-12-31'

 

Thanks but it seems not to work because shows one result without any sense.

Link to comment
Share on other sites

×
×
  • Create New...