Re: insert question.. - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: insert question..
Date
Msg-id 20030611145723.GA10356@wolff.to
Whole thread Raw
In response to insert question..  ("Williams, Travis L, NPONS" <tlw@att.com>)
List pgsql-general
On Wed, Jun 11, 2003 at 10:45:05 -0400,
  "Williams, Travis L, NPONS" <tlw@att.com> wrote:
> I'm looking for an example on how to insert static data and information from a select at the same time..
>
> currently I'm doing:
>
> insert into performance (start,finish) select min(poll_time),max(poll_time) from poll
>
> I need to add a 3rd field that is static so I would have something like this
>
>
> insert into performance (name,start,finish) travis,select min(poll_time),max(poll_time) from poll

If travis is really a constant then you could do:
insert into performance (name,start,finish)
  select 'travis', min(poll_time), max(poll_time) from poll;

Another option that might be faster (if there is an index on poll_time)
because you are using max and min is:
insert into performance (name,start,finish)
  values ('travis',
    (select poll_time from poll order by poll_time limit 1),
    (select poll_time from poll order by poll_time desc limit 1))

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: How to find the definition of a sequence ?
Next
From: Thomas Kellerer
Date:
Subject: Re: insert question..