** NORMAS DEL FORO **
Inicio del foro Inicio del foro > Access y VBA > Access y VBA
  Mensajes nuevos Mensajes nuevos RSS - Comparar valores de 2 tablas
  Preguntas frecuentes Preguntas frecuentes  Buscar en el foro   Eventos   Registro Registro  Iniciar sesion Iniciar sesion

Tema cerradoComparar valores de 2 tablas

 Responder Responder
Autor
Mensaje
Jorge33 Ver desplegable
Habitual
Habitual


Unido: 09/Abril/2019
Localización: madrid
Estado: Sin conexión
Puntos: 58
Enlace directo a este mensaje Tema: Comparar valores de 2 tablas
    Enviado: 26/Noviembre/2019 a las 10:04
Hola:

Tengo 2 tablas, en una tengo las ventas de cada tienda por meses. Algo así

Tienda             01       02    03

Madrid             33        25    12

Burgos             12        55     43

Y por otro lado una tabla en la que tengo lo que se vende de cada tienda:

Tienda       Fecha_venta   Pedidos

Madrid        21/03/2019         2 

Madrid        18/01/2019         3

Burgos        17/06/2019         4

Burgos        13/02/2019         7

 

Necesito comprobar que la suma de los valores por mes de la tabla 2 se corresponden con la tabla 1.

Con una consulta de totales he llegado a esto:

Tienda      mes       total ventas

Madrid       1                   3

Madrid       3                   2

Burgos       2                   7

El problema es que al tener los resultados en vertical no se como compararlos con la otra tabla que está en horizontal.

¿como podría comparar las 2 tablas?

 

Muchas gracias

< x="0" y="0" width="99999" height="99999" id="hc_extension_off">< x="0" y="0" width="99999" height="99999" id="hc_extension_highcontrast">< x="0" y="0" width="99999" height="99999" id="hc_extension_highcontrast_back">< x="0" y="0" width="99999" height="99999" id="hc_extension_grayscale">< x="0" y="0" width="99999" height="99999" id="hc_extension_grayscale_back">< x="0" y="0" width="99999" height="99999" id="hc_extension_invert">< x="0" y="0" width="99999" height="99999" id="hc_extension_invert_back">< x="0" y="0" width="99999" height="99999" id="hc_extension_invert_grayscale">< x="0" y="0" width="99999" height="99999" id="hc_extension_yellow_on_black">< x="0" y="0" width="99999" height="99999" id="hc_extension_yellow_on_black_back">
Arriba
mounir Ver desplegable
Colaborador
Colaborador


Unido: 09/Febrero/2009
Localización: Asturias-España
Estado: Sin conexión
Puntos: 6479
Enlace directo a este mensaje Enviado: 26/Noviembre/2019 a las 10:41
Hola!

Convierte la consulta de la segunda tabla en Consulta de Referencias Cruzadas y ya lo tienes.
Un Saludo.
Arriba
Jorge33 Ver desplegable
Habitual
Habitual


Unido: 09/Abril/2019
Localización: madrid
Estado: Sin conexión
Puntos: 58
Enlace directo a este mensaje Enviado: 26/Noviembre/2019 a las 12:16
Gracias.
O no lo hago bien o no me funciona.
Me sale algo así:
            cuenta      01    02    03   04   05   06   07       
Madrid      2           1              1
Burgos      1                                                     1

Así pierdo la suma en cada mes. ¿como puedo hacerlo?
< x="0" y="0" width="99999" height="99999" id="hc_extension_off">< x="0" y="0" width="99999" height="99999" id="hc_extension_highcontrast">< x="0" y="0" width="99999" height="99999" id="hc_extension_highcontrast_back">< x="0" y="0" width="99999" height="99999" id="hc_extension_grayscale">< x="0" y="0" width="99999" height="99999" id="hc_extension_grayscale_back">< x="0" y="0" width="99999" height="99999" id="hc_extension_invert">< x="0" y="0" width="99999" height="99999" id="hc_extension_invert_back">< x="0" y="0" width="99999" height="99999" id="hc_extension_invert_grayscale">< x="0" y="0" width="99999" height="99999" id="hc_extension_yellow_on_black">< x="0" y="0" width="99999" height="99999" id="hc_extension_yellow_on_black_back">
Arriba
Jorge33 Ver desplegable
Habitual
Habitual


Unido: 09/Abril/2019
Localización: madrid
Estado: Sin conexión
Puntos: 58
Enlace directo a este mensaje Enviado: 26/Noviembre/2019 a las 12:37
He tenido que añadir una columna de 1 para que se pueda hacer pero ya funciona.

Muchas gracias

Se puede cerrar el tema
< x="0" y="0" width="99999" height="99999" id="hc_extension_off">< x="0" y="0" width="99999" height="99999" id="hc_extension_highcontrast">< x="0" y="0" width="99999" height="99999" id="hc_extension_highcontrast_back">< x="0" y="0" width="99999" height="99999" id="hc_extension_grayscale">< x="0" y="0" width="99999" height="99999" id="hc_extension_grayscale_back">< x="0" y="0" width="99999" height="99999" id="hc_extension_invert">< x="0" y="0" width="99999" height="99999" id="hc_extension_invert_back">< x="0" y="0" width="99999" height="99999" id="hc_extension_invert_grayscale">< x="0" y="0" width="99999" height="99999" id="hc_extension_yellow_on_black">< x="0" y="0" width="99999" height="99999" id="hc_extension_yellow_on_black_back">
Arriba
 Responder Responder
  Compartir tema   

Ir al foro Permisos de foro Ver desplegable