Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
dear sir/ma'am

i have a problem to fetch data

my table is in the form

rollno maxmark obtmark
1 100 60
1 100 70
1 100 70
2 100 65
2 100 80

but i found the outputr like

rollno maxmark obtmark percentage
1 300 200 66.66
2 200 145 72.5


please help me regarding this
Posted
Comments
Ron Beyer 11-Jun-13 23:15pm    
Can you post your SQL or any other information on how you are getting or displaying this data?
ankur789 11-Jun-13 23:20pm    
sir in my table i have 300(100+100+100)maxmarks and 200(60+70+70)obtmarks
i want the output given in my ques.
i do'nt understand how i do it ,am i use case or anyother
ankur789 11-Jun-13 23:20pm    
above comment is for rollno1

1 solution

Simple SQL like this should get you pretty close to where you want to be.

SQL
select rollno, sum(maxmark), sum(obtmark), (sum(maxmark)/sum(obtmark))*100 as percentage
from TABLENAME
group by rollno
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900