Skip to content
Advertisement

How to group and order rows with different date values in SQL

I have a result like this:

Query is pretty simple:

I need to group them, get sum of amount and order by date. Notice that date values are not the same. I can’t group results because of this. Important thing is i need to order by Date column. This is the result i want:

I’m trying this code but sql gave me an error that i need to use Date column in group by clause.

I’m very new to SQL, can anyone suggest how can i solve that problem please?

Advertisement

Answer

You want aggregation, but you need an aggregation function for the ordering as well:

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