Re: Can EXCEPT Be Used for To Solve This Problem?

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Can EXCEPT Be Used for To Solve This Problem?
Дата
Msg-id 20050824233449.GA12396@winnie.fuhr.org
обсуждение исходный текст
Ответ на Can EXCEPT Be Used for To Solve This Problem?  ("Lane Van Ingen" <lvaningen@esncc.com>)
Ответы Re: Can EXCEPT Be Used for To Solve This Problem?  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-sql
On Wed, Aug 24, 2005 at 04:47:16PM -0400, Lane Van Ingen wrote:
> Given the following data in a table named 'foo' :
>      id   update_time           description
>      2    2005-08-24 00:10:00   transaction1
>      2    2005-08-24 00:22:00   transaction2
>      2    2005-08-24 00:34:00   transaction3
>      2    2005-08-24 00:58:00   transaction4
> 
> I want to select 2nd oldest transaction from foo (transaction 3). The
> solution below
> works, but I think there may be a better way. Does anyone else have a better
> idea?

Do you want the 2nd oldest transaction from the entire table?  If
so then the following should work:

SELECT *
FROM foo
ORDER BY update_time
OFFSET 1
LIMIT 1;

If that's not what you're after then please elaborate.

-- 
Michael Fuhr


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

Предыдущее
От: "Lane Van Ingen"
Дата:
Сообщение: Can EXCEPT Be Used for To Solve This Problem?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Can EXCEPT Be Used for To Solve This Problem?