SQL Query with ORDER BY Part 2
- by Brett
Hi SQL'ers,
This is a followup question to:
SQL Query with ORDER BY
But I think the SQL logic is going to be quite different, so I am posting it as separate question.
I am trying to extend my sql SELECT query it and having some trouble:
I have the table:
id type radius
-------------------------
1 type1 0.25
2 type2 0.59
3 type1 0.26
4 type1 0.78
5 type3 0.12
6 type2 0.45
7 type3 0.22
8 type3 0.98
and I am trying to learn how to SELECT the second smallest radius for each given type. So the returned recordset should look like:
id type radius
-------------------------
3 type1 0.26
2 type2 0.59
7 type3 0.22
(Note: in the referenced question, I was looking for the lowest radius, not the second lowest radius).
I am assuming I have to use LIMIT and OFFSET, but if I use the MIN() won't that return a distinct record containing the minimum radius?
Does anyone have any thoughts on how to attack this?
Many thanks,
Brett