Get percentage or sum of records from 2 tables

A

Anonymous

Guest
Guys

I have 2 tables pre_results and post_results. they have the same structure but different data.

pre_results is used for storing data or scores of students who took the pre exam post_results is for the post exams.

both have the same columns date, coursecode, q1, q2... q10 (for storing 1 for correct and 0 for wrong) and total. both tables have prefix of pre and post.

now the problem is i am going to make a report of both tables

i will get the summary with percentage of a specific course with specific range date.

how can i get the percentage of all correct answers for the entire test if 1 record is stored on one row of data?
i can use the count right? but i have to get other records too.

waaah. please help.

My report should be like this

Coursename: PHP

DATE----------------------PRE RESULT------------------------------POST RESULT
March 1, 2005------------- 70% -------------------------------------- 80%
June 2, 2005--------------- 80% ------------------------------------- 85%

Average-------------------- 75% ------------------------------------- 82.5 %

thank you
 
you will make a inner join considering all the those who appeared in pre are there in post

Code:
select a.colnames, b.colnames
from pre_table a, post_table b
where 
a.date = b.date and
a.student_id = b.student_id
 
hi thanks for the reply, i did your query but it gives me all the records, i just need i record for the series of records

lets say in my database 5 students answered for the march 1 2005. and 2 students answered for june 2, 2005 it appears like this.

DATE----------------------PRE RESULT------------------------------POST RESULT
March 1, 2005--------------- % ----------------------------------------- %
March 1, 2005--------------- % ----------------------------------------- %
March 1, 2005--------------- % ----------------------------------------- %
March 1, 2005--------------- % ----------------------------------------- %
March 1, 2005--------------- % ----------------------------------------- %
June 2, 2005----------------- % ---------------------------------------- %
June 2, 2005----------------- % ---------------------------------------- %

Average---------------------- % ---------------------------------------- %


it just means that in my pre_result table i have 5 records with the same coursename but different values for the other tables like from q1 - q10. and in my post result table i have 2 records.

i just need the a summary of all the courses with the percentage of correct answers.

lets say with that 5 records its just 1 because they have the same id. i need to get the percentage of all 5 records.

i know this is really hard because you dont see my tables.
 
Back
Top