| От | Tom Lane |
|---|---|
| Тема | Re: Grabbing Newest Records From Duplicates |
| Дата | |
| Msg-id | 7240.1174059340@sss.pgh.pa.us обсуждение |
| Ответ на | Grabbing Newest Records From Duplicates ("Travis Whitton" <tinymountain@gmail.com>) |
| Ответы |
Re: Grabbing Newest Records From Duplicates
|
| Список | pgsql-sql |
"Travis Whitton" <tinymountain@gmail.com> writes:
> Given the following test table, I want to grab only the newest record and
> disregard any older duplicates based on name. Is this the most efficient way
> to do it?
No, it's gonna be pretty awful. The best way I know of involves
DISTINCT ON (see the "weather reports" example in the SELECT reference
page). Unfortunately that's a Postgres-only construct. If you want
something portable then you'll need something messy with subqueries...
regards, tom lane
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера