Am working on a project that gets subject average, subject position and class position of a student in a class.
My challenge now is how to get Subject Position and class position of a student in a class. Please i need help.
This is my Table arrangement:
table name=academic_result
<?php
// Subject Ranking
$stmt = $link->prepare("SELECT REG, term, subject, session, total, dense_rank() OVER( partition by subject ORDER BY total desc )
AS 'dense_rank' FROM academic_result WHERE class=? AND term=? AND session=?");
$stmt->bind_param("sss", $class, $term, $session);
$stmt->execute();
$checkSubject = $stmt->get_result();
$result_SUBPO = $checkSubject->fetch_assoc();
echo ordinal($result_SUBPO['dense_rank']);
?>
REG | class | session | term | subject | total
01 | js1 |200/2001 | 1T | csc101 | 85
02 | js1 |200/2001 | 1T | csc101 | 90
01 | js1 |200/2001 | 1T | bus101 | 70
02 | js1 |200/2001 | 1T | bus101 | 90
01 | js1 |200/2001 | 1T | chem101 | 75
02 | js1 |200/2001 | 1T | chem101 | 85
My query Output looks link this
Subject | Total | Subject ranking | class position
csc101 | 85 |1st |
bus101 | 70 |1st |
chem101 | 75 |1st |
this what the query out put looks like, this is the result of a student with Reg No(01). Subject ranking(subject position) for a student is always 1st, this is where am having problem. The subject ranking (subject position) is alto vary depending on their subject total score.
I still want to get Class position of a student from the table.