I have a table, db.Men
, that has three columns
- nvarchar "Name"
- int "Age"
- nvarchar "Status"
The Status
column has three values only: "Happy", "Normal", and "Bad".
I need to count the average and standard deviation of the ages of "Happy" or "Normal":
using System.Linq
var ctx = new DataClasses1DataContext();
double? avg = (from n in ctx.men
where n.status == "Happy"
select n.age).Average();
int? sum = (from n in ctx.men
where n.status == "Happy"
select n.age).Sum();
I computed the average and the sum. How can I compute the standard deviation in this conditional status?