Skip to content
Advertisement

How to calculate MAX(SUM()) in postgresql in particular to query below

I am trying to get MAX(SUM()) in PostgreSQL, which is not possible directly in PostgreSQL. I am trying to get the result by any method, but unable to get the desired result. My table is like this –

This is sample data

In this i want to get the user with highest sum of credit_rupee for a particular day.

The result i want is

The problem is i cannot select all three user_id,max(),date without GROUP BY date and user_id which makes it difficult to arrive at the result mentioned above.

i have tried many combinations like


Etc., But no matter however tried unable to get the result which i wanted. Can anybody help me how to arrive at the result? Thanks

Advertisement

Answer

This query will give you exactly what you want:

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