Mark S
Mark S

Reputation:

How to use 'SUM' to calculate amount1 and amount2?

How to use 'SUM' to calculate amount1 and amount2 that is in my result, sum2?

 var sum2 = (from p in db.tbl_relacijes  
           select p);  

 Button12.Text = (sum2.Sum());

Upvotes: 1

Views: 420

Answers (3)

veljkoz
veljkoz

Reputation: 8514

I must say I don't really get the question, but maybe this is what you're looking for?

var sum2 = (from p in db.tbl_relacijes  
           select p);  

 Button12.Text = (sum2.Sum(t => t.amount1 + t.amount2)).ToString();

Upvotes: 1

Binary Worrier
Binary Worrier

Reputation: 51719

Difficult to be sure what you're asking, assuming amount1 and amount2 columns in the table?

Button12.Text = sum2.Sum(row => row.amount1 + row.amount2).ToString();

Upvotes: 2

Singleton
Singleton

Reputation: 3679

I am assuming that relacijes has two columns for amount1 and amount2

Button12.Text=sum2.Sum(a=>a.amount1 + a.amount2).ToString();

Upvotes: 2

Related Questions