Top 3 values for each group in PGSQL - Mailing list pgsql-sql

From Ila B.
Subject Top 3 values for each group in PGSQL
Date
Msg-id 67FB61BF-CF8F-440E-B4C5-B6F72D61A9C7@gmail.com
Whole thread Raw
Responses Re: Top 3 values for each group in PGSQL
Re: Top 3 values for each group in PGSQL
List 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 by date:

Previous
From: github kran
Date:
Subject: Re: PostgreSQL DB Maintenance and Partitioning to keep data longer.
Next
From: hubert depesz lubaczewski
Date:
Subject: Re: Top 3 values for each group in PGSQL