Re: [SQL] DISTINCT ON: speak now or forever hold your peace

Поиск
Список
Период
Сортировка
От Julian Scarfe
Тема Re: [SQL] DISTINCT ON: speak now or forever hold your peace
Дата
Msg-id 388D5F2C.DBD639D@callnetuk.com
обсуждение исходный текст
Ответ на DISTINCT ON: speak now or forever hold your peace  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [SQL] DISTINCT ON: speak now or forever hold your peace  (Peter Eisentraut <e99re41@DoCS.UU.SE>)
Список pgsql-sql
Tom Lane wrote:
> 
> If I don't hear loud hollers very soon, I'm going to eliminate the
> DISTINCT ON "feature" for 7.0.  As previously discussed, this feature
> is not standard SQL and has no clear semantic interpretation.

I use 'distinct on' to get the most recent reports for each of a group of
locations.  E.g.:

create table reports (
location     varchar(16),
report_time  datetime,
report_text  text);

select distinct on location * from reports where location ~~ 'Lond%' order by
location, reporttime desc;

to get the tuples that offer the most recent reports for each of London,
Londonderry, Londy etc.

Is there an alternative?

Julian Scarfe


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: [SQL] Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace