I have this table in a database
| stid | term | subjects | score |
|---|---|---|---|
| 1 | Term 1 | English | 70 |
| 1 | Term 1 | Math | 80 |
| 1 | Term 1 | Science | 98 |
| 1 | Terminal | English | 85 |
| 1 | Terminal | Math | 90 |
| 1 | Terminal | Science | 100 |
I need to retrive data to display like this in a html table
| SUBJECT | TERM ONE | TERMINAL | AVERAGE |
|---|---|---|---|
| English | 70 | 85 | 112.5 |
| Math | 70 | 85 | 85 |
| Science | 98 | 100 | 99 |
I’m new in SQL Queries I tried alot to run different sql command but i did not succeeded. I need your help.
my last query was this:
SELECT DISTINCT(subject),score FROM `examresults` WHERE stid='STD-1' GROUP BY subject,term