Say I have the following table:
Type |Price |Time
-------------------------
Drill | 5 | ---
Drill | 2 | ---
Drill | 1 | ---
Plant | 3 | ---
Plant | 4 | ---
Light Plant | 9 | ---
Light Plant | 21 | ---
Light Plant | 1 | ---
Light Plant | 5 | ---
I would like to get the 2 most recent records of each Type. So this is the output I'm expecting:
Drill | 5
Drill | 2
Plant | 3
Plant | 4
Light Plant | 9
Light Plant | 21
I have a working solution with multiple queries i.e. each query looks for the 2 most recent records of a specific Type. Loop over all the unique Types. However, I want to do it with a single query.