I have the following issue, I need to remove duplicate values from a specific column I query. No deleting!(ClassID)
| SchoolNo | Schoolyear | Schoolgrade | Classname | ClassId |
|---|---|---|---|---|
| 65432 | 2001 | 5 | ab | 441 |
| 65432 | 2001 | 5 | cd | 442 |
| 65432 | 2001 | 6 | a | 443 |
| 65432 | 2001 | 6 | b | 444 |
| 56838 | 2001 | 5 | ab | 445 |
| 56838 | 2001 | 5 | cd | 446 |
| 56838 | 2001 | 6 | ab | 445 |
| 56838 | 2001 | 6 | ef | 447 |
| 12726 | 2001 | 5 | ms | 448 |
| 12726 | 2001 | 6 | ms | 448 |
If you look at the values of classId I have repeated class numbers because some special schools sometimes put 2 classes together for both grades. The problem is my query needs to show only 1 classid value. No repeats. Therefore we can remove any extra class that is repeated in value and only show for grade 5.
In other words my table should at end up looking like this.
| SchoolNo | Schoolyear | Schoolgrade | Classname | ClassId |
|---|---|---|---|---|
| 65432 | 2001 | 5 | ab | 441 |
| 65432 | 2001 | 5 | cd | 442 |
| 65432 | 2001 | 6 | a | 443 |
| 65432 | 2001 | 6 | b | 444 |
| 56838 | 2001 | 5 | ab | 445 |
| 56838 | 2001 | 5 | cd | 446 |
| 56838 | 2001 | 6 | ef | 447 |
| 12726 | 2001 | 5 | ms | 448 |
The code generally looks like this.
select schoolno,schoolyear,schoolgrade,classname,classId
from classgroup cg
How should I approach this?
