Rico Brouwer - 1 month ago 7

C# Question

I have an application(C#) that manages a stock level for every storage unit.

But now i want a complete overview of the stock level of every product from every stock unit together.

For example i have

`50`

`25`

`select StockLevel`

from Supply

where ProductID = '1'

And put the result in a textbox it will always gives me the first stocklevel of

Is there a way i can combine these results in an easy way?

Answer

If you want to *combine*, you want an *aggregate function*, `sum`

in your case:

```
select sum(StockLevel)
from Supply
where ProductID = '1'
```

and get the apples being summed up: `75`

which is `50 + 25`

Source (Stackoverflow)

Comments