I have a table of students that has some data about whether or not they attent a tutorial etc. There is an extract below.
| id | studentid | name | present |
| 1 | 111 | John | 1 |
| 2 | 222 | Kate | 0 |
| 3 | 333 | Matt | 1 |
| 4 | 111 | John | 0 |
| 5 | 111 | John | 1 |
I can do a count to say when eg studentid=111 and present = 1 and when studentid=111 and present = 0.
But I can’t work out these two things.
i. Can I do just one count query rather than doing a seperate count for each?
Currently with my two seperate queries I am getting eg
studentid=111 and present = 1
| name | present |
| John | 12 |
studentid=111 and present = 0
| name | absent |
| John | 4 |
But I would ideally like
| name | present | absent |
| John | 12 | 4 |
ii.I want to see those students who have been to less than 75% of the classes. I have done some reading about the avg function however I am not sure how to implement something for this?
To list the students that have been to less than 75% of classes: