日期:2014-05-17 浏览次数:20677 次
select StuID as 学号, (select TrueName from DB_Users where DB_Score.StuID=DB_Users.StuID) as 姓名 ,
sum(case ClassID WHEN '25' THEN Score END )AS 语文,
sum(case ClassID WHEN '26' THEN Score END )AS 数学,
sum(Score) as 总分,AVG(Score) as 平均分,
Rank() over ( order by sum(Score) ) as 名次
from DB_Score Where TypeID=1 and ImportTime='2014-1-14'
group by DB_Score.StuID order by 总分
var q = from a in DB_Score?
group a by a.StuID into k
select new {
stuNum = k.Key,
lang = k.Where(b=>b.ClassID==1).Sum(b=>b.Score),
math = k.Where(b=>b.ClassID==2).Sum(b=>b.Score),
};
var p = q.Select(a=>new {
stuNum = a.stuNum,
lang = a.lang,
math = a.math,
total = (a.lang+a.math)
});
foreach(var item in p.OrderByDescending(a=>a.total)){}