Re: question about query

Поиск
Список
Период
Сортировка
От Linos
Тема Re: question about query
Дата
Msg-id 4E0C77DD.1060201@linos.es
обсуждение исходный текст
Ответ на Re: question about query  (Craig Ringer <craig@postnewspapers.com.au>)
Список 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


В списке pgsql-general по дате отправления:

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: question about query
Следующее
От: "David Johnston"
Дата:
Сообщение: Re: question about query