Re: question about query

From: Linos <info(at)linos(dot)es>
To: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: question about query
Date: 2011-06-30 13:19:25
Message-ID: 4E0C77DD.1060201@linos.es
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

sorry, i have more searching for a way to do something like this but i should
have posted the tables anyway, i have any more documents but all have a
structure like this:

invoices:

CREATE TABLE factura
(
id_factura serial NOT NULL, -- invoice id
id_cliente integer NOT NULL, -- customer relation
fecha date NOT NULL, -- date of invoice
importe numeric(10,2) NOT NULL, --total invoice qty
time_stamp_creacion timestamp without time zone NOT NULL DEFAULT now()
CONSTRAINT factura_cabecera_pkey PRIMARY KEY (id_factura)
) WITH (
OIDS=FALSE
);

payments:

CREATE TABLE factura_fecha_cobro
(
id_factura integer NOT NULL, --invoice id
id_cobro integer NOT NULL, --number of payment for this invoice
fecha date NOT NULL, --date of payment
importe numeric(10,2) NOT NULL, --qty paid
time_stamp_creacion timestamp without time zone NOT NULL DEFAULT now(),
CONSTRAINT factura_fecha_cobro_pkey PRIMARY KEY (id_factura, id_cobro),
CONSTRAINT factura_fecha_cobro_id_factura_fkey FOREIGN KEY (id_factura)
REFERENCES factura (id_factura) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE CASCADE
)
WITH (
OIDS=FALSE
);

Regards,
Miguel Angel.

El 30/06/11 15:11, Craig Ringer escribió:
> On 30/06/2011 9:00 PM, Linos wrote:
>> how could i calculate this pending column that does not exists in the database
>> and i need to be based on last result row? I would like to get with raw SQL
>> but the need to use any procedural language would not be a problem.
>>
> Without knowing how you've structured your data in the database, that's pretty
> much impossible to answer.
>
> What are your table definitions?
>
> What does your raw data currently look like? Show some example rows.
>
> --
> Craig Ringer

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2011-06-30 13:44:50 Re: question about query
Previous Message Craig Ringer 2011-06-30 13:11:21 Re: question about query