SELECT [User_ID], [Exam_Id], [Score], [TotalScore], [Cnt],
(select count(t.Score) from (Select Distinct Score From V_ExamStat) t Where t .Score>=V_ExamStat.Score) AS '全表排名',
(select count(t2.Score) from (Select Distinct Exam_Id, Score From V_ExamStat) t2 Where t2 .Score>=V_ExamStat.Score And t2.Exam_Id=V_ExamStat.Exam_Id) AS '单场考试排名'
FROM V_ExamStat
(select count(t.Score) from (Select Distinct Score From V_ExamStat) t Where t .Score>=V_ExamStat.Score) AS '全表排名',
(select count(t2.Score) from (Select Distinct Exam_Id, Score From V_ExamStat) t2 Where t2 .Score>=V_ExamStat.Score And t2.Exam_Id=V_ExamStat.Exam_Id) AS '单场考试排名'
FROM V_ExamStat