Ayuda sobre joins

From: mPerez mPerez <stylergarcia(at)gmail(dot)com>
To: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Ayuda sobre joins
Date: 2010-01-22 18:11:26
Message-ID: c6f2c7f51001221011y78c18f57o1a6464fe772b2bba@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Hola a todos, quisiera que me ayuden de como es la manera mas eficiente de
sacar una consulta, si utilizando joins, subconsultas, etc.
Tengo tres tablas

id documento fecha producto item serie
1 09 01/01/2009 01001 1 SERIEX1
1 09 01/01/2009 01001 1 SERIEX2
1 09 01/01/2009 01002 2 SERIEY1
1 09 01/01/2009 01002 2 SERIEY2
1 01 01/01/2009 01001 1 SERIEX3
1 01 01/01/2009 01002 2 SERIEY3
1 01 01/01/2009 01002 3 .NULL.

*****cabecera
id documento fecha
1 09 01/01/2009
2 01 01/01/2009

*****detalle
id item producto unidades
1 1 01001 2
1 2 01002 2
2 1 01001 1
2 2 01002 1
2 3 01003 2

**** series
id item producto serie
1 1 01001 SERIEX1
1 1 01001 SERIEX2
1 2 01002 SERIEY1
1 2 01002 SERIEY2
2 1 01001 SERIEX3
2 2 01002 SERIEY3

Lo que deseo es que salga de la siguiente manera:

id documento fecha producto item serie
1 09 01/01/2009 01001 1 SERIEX1
1 09 01/01/2009 01001 1 SERIEX2
1 09 01/01/2009 01002 2 SERIEY1
1 09 01/01/2009 01002 2 SERIEY2
2 01 01/01/2009 01001 1 SERIEX3
2 01 01/01/2009 01002 2 SERIEY3
2 01 01/01/2009 01003 3 .NULL.

Muchas gracias por su tiempo y ayuda.
Saludos

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Jaime Casanova 2010-01-22 18:37:04 Re: Ayuda sobre joins
Previous Message Carlos Bazán 2010-01-22 17:23:05 Re: Que puede envidiar postgresql a oracle ?