| От | Andreas Kretschmer |
|---|---|
| Тема | Re: Keeping top N records of a group |
| Дата | |
| Msg-id | 20160514123434.GA28259@tux обсуждение исходный текст |
| Ответ на | Keeping top N records of a group (Alex Magnum <magnum11200@gmail.com>) |
| Список | pgsql-general |
Alex Magnum <magnum11200@gmail.com> wrote: > Hi, > i want to archive data and am looking for a query to replace a rather slow > function i am currently using. > > The idea is that for every sym and doc_key I want to keep the records of the > top 2 sources. Eg. in below table I want to archive sounds like a case for window-functions here (maybe row_number() or rank()), please read that for the start: http://stackoverflow.com/questions/7613785/postgresql-top-n-entries-per-item-in-same-table Regards, Andreas Kretschmer -- Andreas Kretschmer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера