Start New Discussion within our Databases Community

Hi I am trying to cross join 3 tables and use the values from this to calculate cumulative Accuracy for each student.

But I am missing some students name when they dont have values in one of the tables.


@mysql_select_db($database) or die( "Unable to select database");

// to have the student names stored in array

$qr="SELECT DISTINCT(student) from binnerslisttranslit order by student ASC";





for ($re=1;$re<$ke;$re++)

$query="SELECT  student1,Accuracy1,Accuracy2,Accuracy3,(Accuracy1+Accuracy2+Accuracy3)/3 as Accuracy 
(SELECT student,COUNT(id) as samplesize2,SUM(scores) as Cumulative2,(100-((SUM(scores)/COUNT(id))*100)) as Accuracy2 from  tWeek2Feb2012  where student='$student[$re]'  group by student)
(SELECT student as student1,COUNT(id) as samplesize1,SUM(scores) as Cumulative1,(100-((SUM(scores)/COUNT(id))*100)) as Accuracy1 from  tWeek1Feb2012   where student='$student[$re]'  group by student)
(SELECT COUNT(id) as samplesize3,SUM(scores) as Cumulative1,(100-((SUM(scores)/COUNT(id))*100)) as Accuracy3 from  tWeek3Feb2012   where student='$student[$re]'  group by student)T3;";

$result = mysql_query($query);

// to store student accuracy for each weeks stored in array
while($row = mysql_fetch_array($result))





<table  align='center' border="1" bgcolor="White" cellspacing="2" cellpadding="9">

<td> <?php echo $re; ?> </td>
<td> <?php echo $student[$re]; ?> </td>
<td> <?php echo $Accuracy1[$re]; ?>  </td>

<td> <?php echo $Accuracy2[$re]; ?> </td>

<td> <?php echo $Accuracy3[$re]; ?> </td> 

<td> <?php echo $Accuracy[$re]; ?>   </td>






A test case is a series of SQL statements which create tables, fill them with data and contain the query which poses a problem for you.
It typically consists of
- one or more CREATE TABLE statements to set up the tables,
- several INSERT INTO statements to fill them with test data, and
- a query (THE query) which you have problems with.

This article has been dead for over six months. Start a new discussion instead.