I have a table (`PostgreSQL`) which looks like:

```
id  parentid  name   gradeA gradeB
1              I-1    5       20
2              I-2    5        30
3     1        I-3    17       50
4     1        I-4    5        12

```

I want to get all rows that has `gradeA=5` but, if a row has parentid I want that under grade I will see the grades of the parent.

meaning I want to get:

```
id  parentid  name   gradeA gradeB
1              I-1    5       20
2              I-2    5        30
4     1        I-4    5        20     /gradeA and gradeB are if id=1 not id=4

```