Skip to content
Advertisement

Get the sum of rows using sql query

Suppose I have this table structure:

I want to sum the quantity for the same name and last name and get the result as below

Is it possible to get this result in a single SQL query ?

it is easy to get the SUM with the GROUP BY but did not find a way to keep the Buy and Sell column at the same time.

Advertisement

Answer

Oh, I get it. I think you want aggregation with some additional conditional logic:

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