I have a table like this:
| id | status | grade |
|---|---|---|
| 123 | Overall | A |
| 123 | Current | B |
| 234 | Overall | B |
| 234 | Current | D |
| 345 | Overall | C |
| 345 | Current | A |
May I know how can I display how many ids is fitting with the condition:
The grade is sorted like this A > B > C > D > F,
and the Overall grade must be greater than or equal to the Current grade
Is it need to use CASE() to switch the grade to a number first?
e.g. A = 4, B = 3, C = 2, D = 1, F = 0
In the table, there should be 345 is not match the condition. How can I display the tables below:
| qty_pass_the_condition | qty_fail_the_condition | total_ids |
|---|---|---|
| 2 | 1 | 3 |
and\
| fail_id |
|---|
| 345 |
Thanks.