Fastest way to calculate summary of database field
- by Jo-wen
I have a ms-sql table with the following structure:
Name nvarchar; Sign nvarchar; Value int
example contents:
Test1, 'plus', 5
Test1, 'minus', 3
Test2, 'minus', 1
I would like to have totals per "Name". (add when sign = plus, subtract when sign = minus)
result:
Test1, 2
Test2, -1
I want to show these results (and update them when a new record is added)...
and I'm looking for the fastest solution! [sproc? fast-forward cursor? calculate in .net?]