Hi,
I'm a beginner in PHP/MySql an I have this question:
Lets say I create a table "trimester" with these fields:
Employee, T1, T2, T3, T4
For each Trimester, I enter the total sales of each employee and then, I will group the results by "Total Sales" as follows:
$sql = 'SELECT Employee, T1, T2, T3, T4, SUM( T1 + T2 + T3 + T4 ) AS "Total Sales" FROM `trimester` GROUP BY Employees ORDER BY `Total Sales` ASC LIMIT 0 , 30", $db);
Now I would like to create a column that will show the employee's rank according to his or her total sales and that would be automatically generated, example:
Rank - Employee - T1 - T2 - T3 - T4 - Total Sales
1 John 20 20 20 10 70
1 Joey 30 20 10 10 70
3 Paul 30 10 10 10 60
Since John and Joey have the same total, their rank will be 1 and Paul would be 3rd and not 2nd since John and Joey would share the commission given to 1st and 2nd. In anycase, the "rank" doesn't exist because I don't know how to make it. How do I create the column "rank" (In MySql or in my PHP code?)
Thanks in advance for your help