Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.
Become a Premium Member and unlock a new, free course in leading technologies each month.
var departmentquery = from row in dt.AsEnumerable()
group row by row["department"] into grp
select new {
Sum = grp.Sum(r => r.Field<decimal>("score");
};
select e.departmentId,round(cast(sum(score)as decimal(10,2))/(SELECT sum(score) FROM table),2)
From table t
--joins etc
GROUP BY employeeId
Thanks
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
DataTable dt = new DataTable("department");
dt.Columns.Add(new DataColumn("department"));
dt.Columns.Add(new DataColumn("employeeId"));
dt.Columns.Add(new DataColumn("score",System.Type.GetType("System.Decimal")));
DataRow datarow = dt.NewRow();
datarow[0] = "1";
datarow[1] = "1";
datarow[2] = 10;
dt.Rows.Add(datarow);
datarow = dt.NewRow();
datarow[0] = "1";
datarow[1] = "2";
datarow[2] = 10;
dt.Rows.Add(datarow);
datarow = dt.NewRow();
datarow[0] = "1";
datarow[1] = "3";
datarow[2] = 10;
dt.Rows.Add(datarow);
datarow = dt.NewRow();
datarow[0] = "2";
datarow[1] = "1";
datarow[2] = 10;
dt.Rows.Add(datarow);
datarow = dt.NewRow();
datarow[0] = "2";
datarow[1] = "2";
datarow[2] = 10;
dt.Rows.Add(datarow);
datarow = dt.NewRow();
datarow[0] = "3";
datarow[1] = "1";
datarow[2] = 10;
dt.Rows.Add(datarow);
var departmentquery = from row in dt.AsEnumerable()
group row by row["department"] into grp
where grp.Count() > 1
select new {
deparmtent = grp.Key,
Sum = grp.Sum(r => r.Field<decimal>("score"))
};
Int16 sumTotal = (Int16)dt.AsEnumerable().Sum(x => x.Field<Int16>("score"));
var departmentquery = from row in dt.AsEnumerable()
group row by row["department"] into grp
where grp.Count() > 1
select new {
deparmtent = grp.Key,
Sum = grp.Sum(r => r.Field<Int16>("score")),
sumTotal,
};
Int16 sumTotal = (Int16)dt.AsEnumerable().Sum(x => x.Field<Int16>("score"));
var departmentquery = from row in dt.AsEnumerable()
group row by row["department"] into grp
where grp.Count() > 1
select new
{
deparmtent = grp.Key,
Sum = grp.Sum(r => r.Field<Int16>("score")),
Percentage = 100 * (decimal)grp.Sum(r => r.Field<Int16>("score")) / (decimal)sumTotal,
};
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.