Jump to content

Ayuda SQL ventas por provincias / estado con rango de fechas


Alexistoselli

Recommended Posts


Hola, las consultas de acuerdo a provincia, estado y ciudad puede varias de acuerdo al IDENTIFICADOR, pero te mostraré una idea con ejemplo.

Imaginemos que tenemos :
Una provincia con identificador "1" y "nombre NEW YORK", con rango de fecha menores a '2020-04-24' :

select * 
from ps_orders as ord

left join ps_address as a on a.id_address = ord.id_address_invoice
left join ps_state   as s on s.id_state   = a.id_state
left join ps_zone    as z on z.id_zone    = s.id_zone

where s.id_state   = 1
and   ord.date_add < '2020-04-24'


Ahora si queremos por zona, imaginemos que tenemos : 
Una zona con identificador "1" y "nombre CENTRO", con rango de fecha menores a '2020-04-24' :

select * 
from ps_orders as ord

left join ps_address as a on a.id_address = ord.id_address_invoice
left join ps_state   as s on s.id_state   = a.id_state
left join ps_zone    as z on z.id_zone    = s.id_zone

where z.id_zone = 1
and   ord.date_add < '2020-04-24'

 


Espero te ayude!!.

Edited by luishuaymana (see edit history)
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...