Return all possible combinations for each group I have got a table looks like this one here shows the student ID and all classes this student took:

+-------------+
| ID | Class  |
+-------------+
| 01 |   A    |
| 01 |   B    |
| 01 |   C    |
| 02 |   A    |
| 02 |   C    |
| 02 |   D    |
| 03 |   A    |
| 03 |   B    |
+-------------+


And I would like to convert this table to the one below in order to see all possible combinations of classes for each student.

+----+---------+---------+
| ID | Class 1 | Class 2 |
+----+---------+---------+
| 01 | A       | B       |
| 01 | A       | C       |
| 01 | B       | C       |
| 02 | A       | C       |
| 02 | A       | D       |
| 02 | C       | D       |
| 03 | A       | B       |
+----+---------+---------+


Does anyone know how to get this?
if your dataset is small, something like this could be suitable:

select class1.id ,class1.class class1,class2.class class2 from 
t1 class1,
t1 class2
where
class1.id = class2.id and
class1.class &lt; class2.class
order by id,class1,class2