I have a MySQL table like this:
--------------------------------------------------
| Field | Type | Null | Key | Default | Extra |
--------------------------------------------------
| A | int(11) | NO | PRI | NULL | |
--------------------------------------------------
| B | int(11) | NO | PRI | NULL | |
--------------------------------------------------
| C | int(11) | NO | | NULL | |
--------------------------------------------------
I want to delete ALL rows for each A values, where C value is not in the top 10 (max) C value for that specific A. So there would remain 10 values for the first A, 10 values for the second A, 10 values for the third...
Thank you
Here is an example:
-------------
| A | B | C |
-------------
| 1 | 2 | 5 |
-------------
| 1 | 3 | 2 |
-------------
| 1 | 5 | 9 |
-------------
| 1 | 4 | 7 |
-------------
| 1 | 8 | 4 |
-------------
| 2 | 1 | 5 |
-------------
| 2 | 3 | 8 |
-------------
| 2 | 5 | 7 |
-------------
| 2 | 4 | 6 |
-------------
| 2 | 7 | 9 |
-------------
| 2 | 8 | 1 |
-------------
And let's say I only want the top 2, not the top 10. Then the result:
-------------
| A | B | C |
-------------
| 1 | 5 | 9 |
-------------
| 1 | 4 | 7 |
-------------
| 2 | 7 | 9 |
-------------
| 2 | 3 | 8 |
-------------