I'm looking at all the aggregation functions but can't quite find one that suits this purpose.I would love to get some input on ways to make this faster.
pgsql-sql by date:
Соглашаюсь с условиями обработки персональных данных