我正在尝试编写 linq 查询:
SQL:
select s.s_name, sum(sub.evaluation) as suma from submit_task sub
join student s on s.id=sub.student_id
join study_group g on g.id=s.study_group_id
where g.g_name="abcd"
group by s.s_name
order by suma desc
var groupName = "abcd";
var query =
from submitTask in db.submit_task
join student in db.student
on submitTask.student_id equals student.id
join studyGroup in db.study_group
on student.study_group_id equals studyGroup.id
where studyGroup.g_name == groupName
group submitTask by student.s_name into g
let suma = g.Sum(st => st.evaluation)
orderby suma descending
select new
{
s_name = g.Key,
suma = suma,
};