select FsEfId, Inc = Sum(FsIncA), Gr = sum(FsGrA),
IncCnt = sum (case when FsIncA > 0 then 1 else 0 end)
from FormSub where FsShId = 519 and FsPrvExmS = 'Y'
group by FsEfId
to convert this into LinQ
var data = from Frm in FormSub
where Frm.FsShid == 519 && Frm.FsPrvExms == "Y"
group Frm by Frm.fsEfld into g
select new { ID = g.FsEfId, Inc = g.Sum(p=> p.FsIncA),
Gr = g.Sum(p=> p.FsGra),
IncCnt = g.Count(p=> p.FsIncA >= 1) };
This is a good reference
101 LINQ Samples[
^]