pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Luis Mix <ksql2002@yahoo.com.mx>
To: pgsql-sql@postgresql.org
Date: Thu, 10 Oct 2002 14:14:04 -0500 (CDT)
Message-ID: <20021010191404.6186.qmail@web13008.mail.yahoo.com> (raw)



I have a period of consultation with Fecha1 and Fecha2
and two tables with the follow data:

Table1
----
|Clave_activo | Cantidad |  fecha   |
|             |          |          |
|  clave1     |    5     | 01/02/00 |      
|  clave3     |    7     | 05/05/01 |
|  clave1     |    2     | 03/09/02 |
|  clave2     |    2     | 27/01/01 |
|  clave1     |    1     | 03/11/02 |
|  clave3     |    1     | 25/08/01 |
|  clave2     |    3     | 27/01/00 |
|  clave1     |    8     | 03/12/01 |
|  clave2     |    2     | 27/01/02 |
|  clave1     |    1     | 03/12/00 |
|  clave3     |    2     | 25/08/02 |
|    ..       |   ..     |    ..    |

Y Table2
----
|Clave_activo |  nombre  |
|             |          |
|  clave1     | Product1 |
|  clave3     | Product3 |
|  clave3     | Product3 |
|  clave2     | Product2 |
|  clave1     | Product1 |
|    ..       |   ..     |

I need the SQL Instruction to obtain something like
that:

                  (Sum Product by year)  
|  Nombre  |yearFecha1|00|01|02|YearFecha2  |Total|
| Product1 |  ..      | 6| 8| 3|     ...    | 17  |
| Product2 |  ..      | 3| 2| 2|     ...    | 07  |
| Product3 |  ..      | 7| 1| 2|     ...    | 10  |

For my it is very important their help then has one
week to finish my reports and east already has me a
mess...  
  
If somebody wanted to help me with the other
consultations, please tell me for private, be not that
it bothers, my consultations to the other partners... 




_________________________________________________________
Do You Yahoo!?
La emoción e intensidad del deporte en Yahoo! Deportes. http://deportes.yahoo.com.mx



Message-ID: <20021010191404.6186.qmail@web13008.mail.yahoo.com>
Permalink:  ../20021010191404.6186.qmail@web13008.mail.yahoo.com/
Also on:    postgresql.org/message-id/20021010191404.6186.qmail@web13008.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ksql2002@yahoo.com.mx
  Subject: Re: 
  In-Reply-To: <20021010191404.6186.qmail@web13008.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox