Skip to content
Advertisement

How to fetch a column name which has maximum value from each group in postgres?

I got stack when i try to return maximum value in this query. Here is my query

It is showing me the output like this according the query

enter image description here

But i want the maximum product_service_name. my expected output is

enter image description here

I tried with max(ps.product_service_name) but it did fetch unexpected result. it will be really helpful if anyone help me to solve this

Advertisement

Answer

You can use row_number. If I understand correctly you want to have result with max(app_service_id) by month.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement