Search Postgresql Archives

Re: question about query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux