Top 3 values for each group in PGSQL

Поиск
Список
Период
Сортировка
От Ila B.
Тема Top 3 values for each group in PGSQL
Дата
Msg-id 67FB61BF-CF8F-440E-B4C5-B6F72D61A9C7@gmail.com
обсуждение исходный текст
Ответы Re: Top 3 values for each group in PGSQL  (hubert depesz lubaczewski <depesz@depesz.com>)
Re: Top 3 values for each group in PGSQL  (Thomas Kellerer <spam_eater@gmx.net>)
Список pgsql-sql
Hello,

I’m working on a health database and I’m trying to extract the most popular prescription codes from a custom table I
structuredlike this: 

Year - Code - Count(code)

I want to extract the 3 codes with maximum count for each year. I know I should be using rank() but I don’t really
understandhow this works. 
I am using pgAdmin4 version 3.5 with PostgreSQL 10.6 on Windows 10 Pro and no permission to update.

Thank you in advance,
Ilaria

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

Предыдущее
От: github kran
Дата:
Сообщение: Re: PostgreSQL DB Maintenance and Partitioning to keep data longer.
Следующее
От: hubert depesz lubaczewski
Дата:
Сообщение: Re: Top 3 values for each group in PGSQL