Re: insert question..
| От | Bruno Wolff III | 
|---|---|
| Тема | Re: insert question.. | 
| Дата | |
| Msg-id | 20030611145723.GA10356@wolff.to обсуждение исходный текст  | 
		
| Ответ на | insert question.. ("Williams, Travis L, NPONS" <tlw@att.com>) | 
| Список | 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 по дате отправления: