Can EXCEPT Be Used for To Solve This Problem?

Поиск
Список
Период
Сортировка
От Lane Van Ingen
Тема Can EXCEPT Be Used for To Solve This Problem?
Дата
Msg-id EKEMKEFLOMKDDLIALABIMEMGCBAA.lvaningen@esncc.com
обсуждение исходный текст
Ответы Re: Can EXCEPT Be Used for To Solve This Problem?  (Michael Fuhr <mike@fuhr.org>)
Re: Can EXCEPT Be Used for To Solve This Problem?  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Can EXCEPT Be Used for To Solve This Problem?  (Vivek Khera <vivek@khera.org>)
Список pgsql-sql
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?

select * from foo f1 join (select id, update_time  from foo      except  select id, max(update_time) as update_time
fromfoo  group by id) f2
 
using (id, update_time)
order by 1, 2 desc limit 1;




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

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: Re: how to do a select * and decrypt a column at the same
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: Can EXCEPT Be Used for To Solve This Problem?