'How can I select a table skipping duplicated value postgreSQL

I have a table like this.

id grade_1 grade_2 createdAt
1 1 1 20220304
2 1 1 20220301
3 4 2 20220228

I want to select the current row(in here, id=1) and a row where the grade's value is different with the row I selected.(in here, id=3)

Like This

id grade_1 grade_2 createdAt
1 1 1 20220304
3 4 2 20220228

I tried to use subquery but it doesn't really worked for me. Is there any way to skip the duplicated value when selecting table?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source