I have data in an Oracle table from which I need to select certain rows based on the number of unique values that repeat due to grouping. My data looks like this.

```
| LINE | BUCKET | TERM | COURSE     |
|------|--------|------|------------|
| 1001 | 1      | FA18 | COURSE 101 |
| 1001 | 1      | SP19 | COURSE 102 |
| 1001 | 1      | SP19 | COURSE 103 |
| 1001 | 1      | FA19 | COURSE 104 |
| 1001 | 2      | FA18 | COURSE 101 |
| 1001 | 2      | SP19 | COURSE 102 |
| 1001 | 2      | SP19 | COURSE 103 |
| 1001 | 2      | FA19 | COURSE 104 |
| 2001 | 1      | FA18 | COURSE 201 |
| 2001 | 1      | SP19 | COURSE 202 |
| 2001 | 1      | FA20 | COURSE 203 |
| 2001 | 2      | FA18 | COURSE 201 |
| 2001 | 2      | SP19 | COURSE 202 |
| 2001 | 2      | FA20 | COURSE 203 |
| 2001 | 3      | FA18 | COURSE 201 |
| 2001 | 3      | SP19 | COURSE 202 |
| 2001 | 3      | FA20 | COURSE 203 |

```

There are two lines in the data. The first line (1001) has 2 different buckets and 4 distinct courses. The second line (2001) has 3 different buckets and 3 distinct courses. I need to
select only 1 row for each course in a line and as many buckets as possible. The math is simple:

* Line 1001: 4 (courses) / 2 (buckets) = 2 courses for each bucket
* Line 2001: 3 (courses) / 3 (buckets) = 1 course for each bucket

How do I select a course once per line across multiple buckets to look like this?

```
| LINE | BUCKET | TERM | COURSE     |
|------|--------|------|------------|
| 1001 | 1      | FA18 | COURSE 101 |
| 1001 | 1      | SP19 | COURSE 102 |
| 1001 | 2      | SP19 | COURSE 103 |
| 1001 | 2      | FA19 | COURSE 104 |
| 2001 | 1      | FA18 | COURSE 201 |
| 2001 | 2      | SP19 | COURSE 202 |
| 2001 | 3      | FA20 | COURSE 203 |

```

The solution could be either SQL or python.