Skip to content
Advertisement

Category: Questions

SQL – combine rows conditionally on the value of previous row

My issue I believe is best explained by using an example: Sample Data SO Customer Product Description Quantity Extension Country 01 xxx 123 Product A 01 20.00 USA 02 yyy 456 Product B 02 25.00 China 02 yyy 456 Product B 01 12.50 China 02 yyy 789 Product C 01 50.00 Mexico 03 zzz 789 Product C 01 50.00 Mexico

Adding all values from output SQL

So, i have a query which looks like this: And it gives me back: Is there any way that this query will give me back added value? Just number 860. Kindly please help me :/ Answer You can just sum all the points you got from your query:

Advertisement