I have the below query to obtain the largest value using group by to get the largest size_min value for each model type. However I would like to get the second largest value for size_min using the same premise of which groups by model_type gets the max size_min but obtaining the actual value for price_1 and price_2 like below.
I may have confused you there, but I have also attached a spreadsheet which better illustrates what I would like to do:
SELECT tt.model_ID, tt.model_type, tt.size_min, tt.model_price_1, tt.model_price_2
FROM dbo.Model AS tt INNER JOIN
(SELECT model_type, MAX(size_min) AS MaxMin
FROM dbo.Model E1
GROUP BY model_type) AS groupedtt ON tt.model_type = groupedtt.model_type AND tt.size_min = groupedtt.MaxMin;
I hope this makes sense and thank you for your help in advance.