I have the Table
| id | num | category |
|---|---|---|
| 1 | 101 | A |
| 2 | 102 | B |
| 3 | 101 | C |
| 4 | 101 | D |
| 5 | 104 | F |
| 6 | 105 | G |
| 7 | 106 | H |
and I want to get the values as shown in the following:
| id | num | category |
|---|---|---|
| 2 | 102 | B |
| 4 | 101 | D |
| 5 | 104 | F |
| 6 | 105 | G |
| 7 | 106 | H |
the idea is that only the one with the highest id remains, of those with the same num.
Using DISTINCT, I get a list of the num, but I also need to get the category in the same query.
SELECT DISTINCT num FROM Table;
How can I do it, thank you!