Issue in getting Correct Percentage in the Crystal Report
guide me how to fix this issue and how to show the correct subjectwise percentage, Ranking and overall Class Position in the Crystal Report by using formula or any other way.
I have a data like this
AdmissionNo ClassID SectionID SubjectID Max  Mark   Rank   SubPer
R-000001        72         232          130       50     34       1        68
R-000001        72         232          129       50     30       2        60
R-000001        72         232          128       50     23       3        46
R-000002        72         232          128       50     34       1        68
R-000002        72         232          129       50     23       2        46
R-000002        72         232          130       50     21       3        42
Now, I wrote the following formula to display the SubPer in the crystal report which is showing wrong result:
if sum({tblSetMarks.Mark}, {tblSetMarks.AdmissionNo}) > 0 then
Round(sum({tblSetMarks.Mark},{tblSetMarks.AdmissionNo}) * 100/ sum({tblSetMarks.Max},{tblSetMarks.AdmissionNo}),1) 
else 0
correct result is following by using the sql query
R-000001        72         232          130       50     34       1        68
R-000001        72         232          129       50     30       2        60
R-000001        72         232          128       50     23       3        46
R-000002        72         232          128       50     34       1        68
R-000002        72         232          129       50     23       2        46
R-000002        72         232          130       50     21       3        42
select AdmissionNo,ClassID,SectionID,SubjectID,Max,Mark
,dense_rank() over(partition BY SUM(Max) order by SUM(Mark) DESC) AS RANK 
,Round(sum(Mark) * 100/ sum(Max),1) as Percentage
from tblSetMarks where AdmissionNo='R-000002'
group by AdmissionNo,ClassID,SectionID,SubjectID,Max,Mark