Problems wording a GROUP BY ranked query

Поиск
Список
Период
Сортировка
От Ila B.
Тема Problems wording a GROUP BY ranked query
Дата
Msg-id 5C9EA2E4-4338-4E8D-AD3C-6356CDADE366@gmail.com
обсуждение исходный текст
Список pgsql-novice
Hello,

I have a table which looks like this:
Username | prescription_code | birth_date | prescription_date

I have 5 age classifications: 0-14, 15-24, 25-44, 45-64 and 65+.
I want to extract for each year (using date_part) the three most common prescriptions (maximum count) for each age
classification(using just the date subtraction and converting years in days). 

I would like results to be in the same table, to export it as CSV in an easy way using the IDE (PGAdmin 4, version 3.5
onWindows). I thought about using UNION and CTEs to extract rank, but that would mean writing 5 queries with CTEs. Is
therea better way? 

Thanks,
Ilaria

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

Предыдущее
От: Andreas Kretschmer
Дата:
Сообщение: Re: Elegant way to insert of some value in some tables in shortinstruction
Следующее
От: Gavin M2301
Дата:
Сообщение: error installing on mingw