I have two tables u
and marklist
:
SELECT * from u;
+------+-------+--------+-------+------------+
| id | name | adress | class | DOB |
+------+-------+--------+-------+------------+
| 1 | Arun | kollam | 6 | 1993-02-01 |
| 2 | Anoop | kollam | 6 | 1993-05-11 |
| 2 | Devi | kollam | 6 | 1993-04-16 |
+------+-------+--------+-------+------------+
3 rows in set (0.02 sec)
select * from marklist;
+------+-----------+------------+-------+--------+
| id | subject | markscored | outof | userid |
+------+-----------+------------+-------+--------+
| 1 | biology | 37 | 50 | 1 |
| 2 | chemistry | 48 | 50 | 1 |
| 3 | physics | 48 | 50 | 1 |
| 4 | biology | 45 | 50 | 2 |
| 5 | chemistry | 41 | 50 | 2 |
| 6 | physics | 34 | 50 | 2 |
| 7 | biology | 39 | 50 | 3 |
| 8 | chemistry | 46 | 50 | 3 |
| 9 | physics | 48 | 50 | 3 |
+------+-----------+------------+-------+--------+
9 rows in set (0.00 sec)
And from this two tables I require an output as:
+------+------+---------+-----------+---------+----------------+------------+
| name |class | biology | chemistry | physics | totlmarkscored | percentage |
+------+------+---------+-----------+---------+----------------+------------+